<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=2"><meta name="theme-color" content="#FFF"><meta name="baidu-site-verification" content="code-DvHFUp3jdk"><meta name="baidu-site-verification" content="code-eHnRZZHAeP"><meta name="baidu-site-verification" content="code-EmlZBboqEW"><meta name="baidu-site-verification" content="code-Hf9ZXEHZ41"><meta name="360-site-verification" content="941073b91e9afaf02748ba000ba47e80"><meta name="360-site-verification" content="010bd45f0d523ce46f298dd597ef0289"><meta name="sogou_site_verification" content="hlLPNfmIjv"><meta name="sogou_site_verification" content="y3La2dTB20"><meta name="msvalidate.01" content="03829B28CC46A7AA4B5503897F475BA1"><script>!function(){var s="https://s.ssl.qhres2.com/ssl/ab77b6ea7f3fbf79.js";document.write('<script src="'+s+'" id="sozz"><\/script>')}()</script><script>!function(t,e,c,n,r,a,s){t[c]=t[c]||function(){(t[c].q=t[c].q||[]).push(arguments)},a=e.createElement(n),a.async=1,a.src="https://www.clarity.ms/tag/"+r+"?ref=bwt",s=e.getElementsByTagName(n)[0],s.parentNode.insertBefore(a,s)}(window,document,"clarity","script","8xwpfccwj2")</script><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?1d318b0509ca0909017253ed6f659ae4";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?aea6c1471d6299bdd1c87a0836f18675";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?498ca413655655a62058d6b5d7c62786";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?e19e8161e13f718806b79f49240583b4";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png"><link rel="icon" type="image/ico" sizes="32x32" href="/images/favicon.ico"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="google-site-verification" content="UA-139249935-1"><meta name="baidu-site-verification" content="cOtBu9CtTEIuwJeN"><link rel="alternate" type="application/rss+xml" title="了尘兰若的小坑" href="https://liaochenlanruo.gitee.io/rss.xml"><link rel="alternate" type="application/atom+xml" title="了尘兰若的小坑" href="https://liaochenlanruo.gitee.io/atom.xml"><link rel="alternate" type="application/json" title="了尘兰若的小坑" href="https://liaochenlanruo.gitee.io/feed.json"><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Mulish:300,300italic,400,400italic,700,700italic%7CFredericka%20the%20Great:300,300italic,400,400italic,700,700italic%7CNoto%20Serif%20JP:300,300italic,400,400italic,700,700italic%7CNoto%20Serif%20SC:300,300italic,400,400italic,700,700italic%7CInconsolata:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext"><link rel="stylesheet" href="/css/app.css?v=0.2.5"><meta name="keywords" content="生信软件,代谢组"><link rel="canonical" href="https://liaochenlanruo.gitee.io/post/0.html"><title>基于TidyMass的非靶向代谢组学分析 - 生物信息 | ResearchGo = 了尘兰若的小坑 = liaochenlanruo</title><meta name="generator" content="Hexo 5.4.0"></head><body itemscope itemtype="http://schema.org/WebPage"><div id="loading"><div class="cat"><div class="body"></div><div class="head"><div class="face"></div></div><div class="foot"><div class="tummy-end"></div><div class="bottom"></div><div class="legs left"></div><div class="legs right"></div></div><div class="paw"><div class="hands left"></div><div class="hands right"></div></div></div></div><div id="container"><header id="header" itemscope itemtype="http://schema.org/WPHeader"><div class="inner"><div id="brand"><div class="pjax"><h1 itemprop="name headline">基于TidyMass的非靶向代谢组学分析</h1><div class="meta"><span class="item" title="Created: 2023-04-19 15:45:39"><span class="icon"><i class="ic i-calendar"></i> </span><span class="text">Posted on</span> <time itemprop="dateCreated datePublished" datetime="2023-04-19T15:45:39+08:00">2023-04-19</time> </span><span class="item" title="Symbols count in article"><span class="icon"><i class="ic i-pen"></i> </span><span class="text">Symbols count in article</span> <span>31k</span> <span class="text">words</span> </span><span class="item" title="Reading time"><span class="icon"><i class="ic i-clock"></i> </span><span class="text">Reading time</span> <span>28 mins.</span></span></div></div></div><nav id="nav"><div class="inner"><div class="toggle"><div class="lines" aria-label="Toggle navigation bar"><span class="line"></span> <span class="line"></span> <span class="line"></span></div></div><ul class="menu"><li class="item title"><a href="/" rel="start">ResearchGo</a></li></ul><ul class="right"><li class="item theme"><i class="ic i-sun"></i></li><li class="item search"><i class="ic i-search"></i></li></ul></div></nav></div><div id="imgs" class="pjax"><img src="https://cdn.jsdelivr.net/gh/liaochenlanruo/cdn@master/img/custom/bgs/thumb_105.webp"></div></header><div id="waves"><svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto"><defs><path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z"/></defs><g class="parallax"><use xlink:href="#gentle-wave" x="48" y="0"/><use xlink:href="#gentle-wave" x="48" y="3"/><use xlink:href="#gentle-wave" x="48" y="5"/><use xlink:href="#gentle-wave" x="48" y="7"/></g></svg></div><main><div class="inner"><div id="main" class="pjax"><div class="article wrap"><div class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList"><i class="ic i-home"></i> <span><a href="/">Home</a></span><i class="ic i-angle-right"></i> <span class="current" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><a href="/categories/Bioinformatics/" itemprop="item" rel="index" title="In 生物信息"><span itemprop="name">生物信息</span></a><meta itemprop="position" content="1"></span></div><article itemscope itemtype="http://schema.org/Article" class="post block" lang="en"><link itemprop="mainEntityOfPage" href="https://liaochenlanruo.gitee.io/post/0.html"><span hidden itemprop="author" itemscope itemtype="http://schema.org/Person"><meta itemprop="image" content="/images/head.jpg"><meta itemprop="name" content="Hualin Liu"><meta itemprop="description" content="liaochenlanruo, 分享微生物生物信息学分析方法，欢迎加入QQ群交流945751012，不接受群内广告！"></span><span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization"><meta itemprop="name" content="了尘兰若的小坑"></span><div class="body md" itemprop="articleBody"><div class="gallery" itemscope itemtype="http://schema.org/ImageGallery"><img data-src="https://cdn.jsdelivr.net/gh/liaochenlanruo/cdn@master/img/custom/bgs/thumb_105.webp" itemprop="contentUrl"></div><h1 id="代谢组学常用仪器特点"><a class="anchor" href="#代谢组学常用仪器特点">#</a> 代谢组学常用仪器特点</h1><table border="1"><tr><th>仪器</th><th>特点</th></tr><tr><td>GC-MS</td><td>易挥发，低极性，热稳定的小分子化合物；需衍生化</td></tr><tr><td>LC-MS</td><td>具有一定极性的有机化合物；无需衍生化</td></tr><tr><td>NMR</td><td>无偏性，无损检测；•无需繁琐前处理，便于活体、原位的动态检测</td></tr><tr><td>CE-MS</td><td>高极性化合物，如核酸，蛋白等</td></tr><tr><td>ICP-MS</td><td>无机化合物</td></tr></table><h1 id="lc-qtof原理"><a class="anchor" href="#lc-qtof原理">#</a> LC-QTOF 原理</h1><p>Q-TOF 全称为四极飞行时间质谱仪（Quadrupole Time-of-Flight Mass Spectrometer）。其基本原理是将样品离子通过四极杆进行质量筛选，然后进入飞行时间质谱器（Time-of-Flight Mass Analyzer，ToF），测定其离子的飞行时间，从而得到样品中离子的质量信息。Q-TOF 有正离子模式（positive ion mode, POS）和负离子模式（negative ion mode, NEG）两种电离方式，在检测代谢组时结合使用两种方式可以使代谢物覆盖率更高，检测效果也更好。</p><p>Q-TOF 的工作过程包含以下步骤：</p><p><strong>离子化</strong>：样品通过电喷雾或者 MALDI 等方法被电离成为离子。</p><p><strong>生成离子束</strong>：离子经过引出阱、加速器、光栅偏转镜等装置，形成一个带电的离子束。</p><p><strong>四极杆质量筛选</strong>：离子束进入四极杆，通过高频交变电压（RF）和直流电压（DC）的控制，将不同质量的离子分离出来。</p><p><strong>飞行时间质谱分析</strong>：通过激光或者其他方法对分散的离子束施加助推、聚焦和分析，并且测定其到达检测器所需的时间。不同质量的离子抵达检测器所需要的时间不同，从而可以得到离子的质量信息。</p><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/img/custom/metabolomics/LC-QTOF.png" alt="LC-QTOF原理"><br><font color="#FF0000"><strong>FAQ</strong>：POS 和 NEG 数据的利用。</font><br>负离子和正离子是数据采集时的时候的两种模式生成两套数据，一级分析（MS）结果中是提供 POS 和 NEG 两个检测结果列表的，但是在二级分析（MSMS）结果中，我们将鉴定正负离子模式下鉴定到的物质进行了合并，所以二级分析是针对代谢物来做的，不区分正负离子模式。</p><p><font color="#FF0000"><strong>FAQ</strong>: 当正负离子模式下都检测到了某种物质，如何对该物质的结果进行呈现？</font><br>会根据匹配参数进行取舍，选用匹配参数更好的模式下的数据在二级结果中进行分析。</p><h1 id="数据分析"><a class="anchor" href="#数据分析">#</a> 数据分析</h1><h2 id="下机数据格式转换"><a class="anchor" href="#下机数据格式转换">#</a> 下机数据格式转换</h2><p>以下两个软件二选一，Windows 下建议使用 ProteoWizard，其用法可参考<span class="exturl" data-url="aHR0cHM6Ly9saWFvY2hlbmxhbnJ1by5mdW4vcG9zdC9kZjU3Lmh0bWw=">用 metid 构建代谢组数据库</span>。Linux 下建议使用 massconverter。</p><h3 id="proteowizard"><a class="anchor" href="#proteowizard">#</a> <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL1Byb3Rlb1dpemFyZA==">ProteoWizard</span></h3><p>将 raw data 转换为 <code>mzXML</code> 格式。</p><h3 id="massconverter"><a class="anchor" href="#massconverter">#</a> <span class="exturl" data-url="aHR0cHM6Ly90aWR5bWFzcy5naXRodWIuaW8vbWFzc2NvbnZlcnRlci8=">massconverter</span></h3><p>将 raw data 转换为 <code>mzXML</code> 格式。</p><h4 id="安装"><a class="anchor" href="#安装">#</a> 安装</h4><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span>require<span class="token punctuation">(</span>remotes<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">&#123;</span></pre></td></tr><tr><td data-num="2"></td><td><pre>    install.packages<span class="token punctuation">(</span><span class="token string">"remotes"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token punctuation">&#125;</span></pre></td></tr><tr><td data-num="4"></td><td><pre>remotes<span class="token operator">::</span>install_github<span class="token punctuation">(</span><span class="token string">"tidymass/massconverter"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token comment"># 获取 pwiz</span></pre></td></tr><tr><td data-num="7"></td><td><pre>library<span class="token punctuation">(</span>massconverter<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre>docker_pull_pwiz<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr></table></figure><p><strong>Debug</strong>：如果报错 <code>Error in docker_pull_pwiz() : Please install docker first (https://www.docker.com/get-started)</code> ，则首先确认系统是否已安装 docker，如果未安装，请先安装 docker；如已经安装，则是因为普通用户无运行 docker 的权限，将其添加到 docker 用户组中即可。</p><figure class="highlight shell"><figcaption data-lang="Bash"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># root 模式下运行如下 shell 命令，将用户 lhl 添加到 docker 组中</span></pre></td></tr><tr><td data-num="2"></td><td><pre>gpasswd -a lhl docker</pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># 重启 docker 生效</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token function">service</span> docker restart</pre></td></tr></table></figure><h4 id="设置转换参数"><a class="anchor" href="#设置转换参数">#</a> 设置转换参数</h4><p>此处调用 MSConvert 进行格式转换，期间进行了过滤，主要采用了 <code>Peak Picking</code> ， <code>Subset</code> ，和 <code>Zero Samples</code> 方法。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>parameter <span class="token operator">=</span></pre></td></tr><tr><td data-num="2"></td><td><pre>   massconverter<span class="token operator">::</span>create_msconvert_parameter<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="3"></td><td><pre>     output_format <span class="token operator">=</span> <span class="token string">"mzXML"</span><span class="token punctuation">,</span><span class="token comment"># "mzXML", "mzML", "mz5", "mgf", "text", "ms1", "cms1", "ms2", "cms2"</span></pre></td></tr><tr><td data-num="4"></td><td><pre>     binary_encoding_precision <span class="token operator">=</span> <span class="token string">"64"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="5"></td><td><pre>     zlib <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="6"></td><td><pre>     write_index <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="7"></td><td><pre>     peak_picking_algorithm <span class="token operator">=</span> <span class="token string">"cwt"</span><span class="token punctuation">,</span><span class="token comment"># "vendor" or "cwt"</span></pre></td></tr><tr><td data-num="8"></td><td><pre>     vendor_mslevels <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword">NA</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token comment"># 当前调用的是 cwt，此参数可能无效</span></pre></td></tr><tr><td data-num="9"></td><td><pre>     cwt_mslevels <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword">NA</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token comment"># 如此设置即可</span></pre></td></tr><tr><td data-num="10"></td><td><pre>     cwt_min_snr <span class="token operator">=</span> <span class="token number">0.1</span><span class="token punctuation">,</span><span class="token comment"># minimum signal-to-noise ratio，设为 0.1 即可</span></pre></td></tr><tr><td data-num="11"></td><td><pre>     cwt_min_peak_spacing <span class="token operator">=</span> <span class="token number">0.1</span><span class="token punctuation">,</span><span class="token comment"># minimum peak spacing，设为 0.1 即可</span></pre></td></tr><tr><td data-num="12"></td><td><pre>     subset_polarity <span class="token operator">=</span> <span class="token string">"positive"</span><span class="token punctuation">,</span><span class="token comment"># "any", "positive" or "negative"，根据模式选择</span></pre></td></tr><tr><td data-num="13"></td><td><pre>     subset_scan_number <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token keyword">NA</span><span class="token punctuation">,</span> <span class="token keyword">NA</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token comment"># A two numeric vector. Can be c(NA, NA) if don't use this</span></pre></td></tr><tr><td data-num="14"></td><td><pre>     subset_scan_time <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">60</span><span class="token punctuation">,</span> <span class="token number">300</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token comment"># A two numeric vector. Can be c(NA, NA) if don't use this</span></pre></td></tr><tr><td data-num="15"></td><td><pre>     subset_mslevels <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token comment"># A two numeric vector. Second can be set as NA</span></pre></td></tr><tr><td data-num="16"></td><td><pre>     zero_samples_mode <span class="token operator">=</span> <span class="token string">"removeExtra"</span><span class="token punctuation">,</span><span class="token comment"># "no", "removeExtra", or "addMissing"</span></pre></td></tr><tr><td data-num="17"></td><td><pre>     zero_samples_mslevels <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword">NA</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token comment"># A two numeric vector. Second can be set as NA</span></pre></td></tr><tr><td data-num="18"></td><td><pre>     zero_samples_add_missing_flanking_zero_count <span class="token operator">=</span> <span class="token number">5</span><span class="token comment"># 默认 5 即可</span></pre></td></tr><tr><td data-num="19"></td><td><pre>   <span class="token punctuation">)</span></pre></td></tr></table></figure><h4 id="开始转换"><a class="anchor" href="#开始转换">#</a> 开始转换</h4><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>convert_raw_data<span class="token punctuation">(</span>input_path <span class="token operator">=</span> <span class="token string">"demo_data/raw_data"</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="2"></td><td><pre>                 output_path <span class="token operator">=</span> <span class="token string">"demo_data/mzxml"</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="3"></td><td><pre>                 msconvert_parameter <span class="token operator">=</span> parameter<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="4"></td><td><pre>                 docker_parameters <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="5"></td><td><pre>                 process_all <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span></pre></td></tr></table></figure><h2 id="安装tidymass"><a class="anchor" href="#安装tidymass">#</a> 安装<span class="exturl" data-url="aHR0cHM6Ly90aWR5bWFzcy50aWR5bWFzcy5vcmcv"> tidyMass</span></h2><figure class="highlight bash"><figcaption data-lang="bash"></figcaption><table><tr><td data-num="1"></td><td><pre>mamba <span class="token function">install</span> gcc_linux-64 gxx_linux-64 gfortran_linux-64</pre></td></tr><tr><td data-num="2"></td><td><pre>mamba <span class="token function">install</span> bioconductor-msnbase bioconductor-rdisop r-openxlsx bioconductor-mzr bioconductor-xcms r-rvest r-tidyr r-stringi r-tidyversedyve r-hexbin</pre></td></tr></table></figure><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span>require<span class="token punctuation">(</span>remotes<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">&#123;</span></pre></td></tr><tr><td data-num="2"></td><td><pre>install.packages<span class="token punctuation">(</span><span class="token string">"remotes"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token punctuation">&#125;</span></pre></td></tr><tr><td data-num="4"></td><td><pre>remotes<span class="token operator">::</span>install_github<span class="token punctuation">(</span><span class="token string">"tidymass/masstools"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre>remotes<span class="token operator">::</span>install_github<span class="token punctuation">(</span><span class="token string">"tidymass/tidymass"</span><span class="token punctuation">)</span></pre></td></tr></table></figure><h2 id="原始数据处理"><a class="anchor" href="#原始数据处理">#</a> 原始数据处理</h2><p>调用<span class="exturl" data-url="aHR0cHM6Ly9tYXNzcHJvY2Vzc2VyLnRpZHltYXNzLm9yZy8="> massprocesser</span> 包进行原始数据处理，进行峰检测与对齐，输出 peak table 包括：<br>原始数据导入（read spectra from file）、峰检测（detect mass traces &amp; detect chromatographic peaks）、校正保留时间（Correcting rentention time）、对已鉴定的色谱峰进行保留时间校正、Grouping peaks across samples、输出 peak table。</p><p><strong>数据目录结构</strong></p><ul><li>mzxml/mzxml_ms1_data/<ul><li>POS/<ul><li>Case/*.mzXML</li><li>Control/*.mzXML</li><li>QC/*.mzXML</li></ul></li><li>NEG/<ul><li>Case/*.mzXML</li><li>Control/*.mzXML</li><li>QC/*.mzXML</li></ul></li></ul></li><li>mzxml/mgf_ms2_data/mgf_ms2_data/<ul><li>POS/*.mgf</li><li>NEG/*.mgf</li></ul></li><li>mzxml/sample_info/<ul><li>sample_info_pos.csv</li><li>sample_info_neg.csv</li></ul></li></ul><h3 id="正离子模式"><a class="anchor" href="#正离子模式">#</a> 正离子模式</h3><p><font color="#FF0000">注意：path 指定的路径名不可以数字开头！</font></p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>library<span class="token punctuation">(</span>tidymass<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>process_data<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="3"></td><td><pre>  path <span class="token operator">=</span> <span class="token string">"mzxml_ms1_data/POS"</span><span class="token punctuation">,</span><span class="token comment"># 路径根据实际情况定</span></pre></td></tr><tr><td data-num="4"></td><td><pre>  polarity <span class="token operator">=</span> <span class="token string">"positive"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="5"></td><td><pre>  ppm <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="6"></td><td><pre>  peakwidth <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">60</span><span class="token punctuation">)</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="7"></td><td><pre>  threads <span class="token operator">=</span> <span class="token number">30</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="8"></td><td><pre>  output_tic <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="9"></td><td><pre>  output_bpc <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="10"></td><td><pre>  output_rt_correction_plot <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="11"></td><td><pre>  min_fraction <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="12"></td><td><pre>  group_for_figure <span class="token operator">=</span> <span class="token string">"QC"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="13"></td><td><pre>  snthresh <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="14"></td><td><pre>  prefilter <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">500</span><span class="token punctuation">)</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="15"></td><td><pre>  fitgauss <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="16"></td><td><pre>  integrate <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="17"></td><td><pre>  mzdiff <span class="token operator">=</span> <span class="token number">0.01</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="18"></td><td><pre>  noise <span class="token operator">=</span> <span class="token number">500</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="19"></td><td><pre>  binSize <span class="token operator">=</span> <span class="token number">0.025</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="20"></td><td><pre>  bw <span class="token operator">=</span> <span class="token number">5</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="21"></td><td><pre>  fill_peaks <span class="token operator">=</span> <span class="token boolean">FALSE</span></pre></td></tr><tr><td data-num="22"></td><td><pre><span class="token punctuation">)</span></pre></td></tr></table></figure><ul><li><strong>ppm</strong>：numeric defining the maximal tolerated m/z deviation in consecutive scans in parts per million (ppm) for the initial regions-of-interest (ROI) definition。<font color="#FF0000">此处的 ppm 来源于 xcms 包，但在 xcms 中不同的函数中，含义貌似不一样，需进一步确认。</font></li><li><strong>peakwith</strong>：峰宽，取决于柱子（column）和 LC 系统。numeric (2) with the expected approximate peak width in chromatographic space. Given as a range (min, max) in seconds.</li><li><strong>min_fraction</strong>：如果一个峰出现在至少一组样本中 <code>min_fraction</code> 样本以上（按比例），则将保留该峰值。</li><li><strong>snthresh</strong> ：信噪比阈值。</li><li><strong>prefilter</strong>：c (k, I) 在第一次分析步骤（ROI 检测）中指定预筛选步骤。仅保留包含至少强度 &gt;=I 的 k 个峰的的质量轨迹（Mass traces）。</li><li><strong>fitgauss</strong> ：是否应对每个峰拟合高斯分布。主要影响峰的保留时间位置。</li><li><strong>integrate</strong>：积分方法（1 或 2）。对于 integrate=1，Peak limits 通过在 mexican hat 过滤后的数据上下降（descent）来确定；而对于 integrate=2，则在原始数据上进行下降处理。后一种方法更准确但容易受到噪声的影响，而前一种方法更稳健但不太精确。</li><li><strong>mzdiff</strong> ：representing the minimum difference in m/z dimension required for peaks with overlapping retention times; can be negative to allow overlap. During peak post-processing, peaks defined to be overlapping are reduced to the one peak with the largest signal.</li><li><strong>noise</strong>：设定第一步分析中需要的质心（centroids ）最小强度（intensity &lt; noise 的质心将被省略在感兴趣区域检测之外）。</li><li><strong>binSize</strong> ：将 m/z 轴按照 binSize 划分为多个区间，再对各区间内的离子信号进行聚合。较小的 binSize 使得峰检测更加准确，检测到更多 features，需要更多计算资源。</li><li><strong>bw</strong>：带宽，通常在 5-50 间，这是用于峰值检测的核密度估计 （KDE） 算法中使用的参数。bw 控制估计的 KDE 曲线的平滑度，并确定峰的解析程度。较小的 bw 值将产生更详细的基础峰形表示，在紧密间隔或重叠的峰之间具有更好的分辨率，但也可能产生更高水平的噪声。相反，较大的 bw 值将导致对峰形的估计更平滑、更广义，这有助于降低噪声和杂散检测，但在某些情况下也可能导致峰分辨率降低。bw 值的选择将取决于所分析数据的具体特征以及分析的目标。通常，有必要试验一系列 bw 值，以找到给定数据集的最佳设置。</li><li><strong>fill_peaks</strong>：Fill peaks NA or not。</li></ul><p><strong>结果</strong>：</p><ul><li><p>POS/Result/</p><ul><li><p>object：用于下一步分析</p></li><li><p>Peak_table.csv：用于下一步分析的峰表</p></li><li><p>Peak_table_for_cleaning.csv：删除了 <code>Peak_table.csv</code> 中无用的列，可直接用于后续的数据清洗</p></li><li><p>BPC.pdf：Base peak chromatogram，仅展示 <code>group_for_figure</code> 参数指定组内的样本<br><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_1.png" alt="BPC.pdf"></p></li><li><p>TIC.pdf：Total ion peak chromatogram，经色谱分离流出的组分不断进入质谱，质谱连续扫描采集数据，每一次扫描得到一张质谱图，将每一张质谱图中所有离子强度相加得到总离子流强度。然后以总离子强度为纵坐标，时间为横坐标绘图。<br><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_2.png" alt="TIC.pdf"></p></li><li><p>RT correction plot.pdf<br><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_3.png" alt="RT correction plot.pdf"></p></li><li><p>intermediate_data：中间文件目录，如果需要重新运行 data processing，则需先删除该目录。</p></li></ul><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 加载对象</span></pre></td></tr><tr><td data-num="2"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"mzxml_ms1_data/POS/Result/object"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># 查看 metabolic features 数量</span></pre></td></tr><tr><td data-num="5"></td><td><pre>object</pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># 获取互动图，在 Rstudio 中才能显示</span></pre></td></tr><tr><td data-num="8"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"mzxml_ms1_data/POS/Result/intermediate_data/xdata2"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre>plot <span class="token operator">=</span> massprocesser<span class="token operator">::</span>plot_adjusted_rt<span class="token punctuation">(</span>object <span class="token operator">=</span> xdata2<span class="token punctuation">,</span> group_for_figure <span class="token operator">=</span> <span class="token string">"QC"</span><span class="token punctuation">,</span> interactive <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="11"></td><td><pre></pre></td></tr><tr><td data-num="12"></td><td><pre>plot</pre></td></tr></table></figure></li></ul><h3 id="负离子模式"><a class="anchor" href="#负离子模式">#</a> 负离子模式</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>massprocesser<span class="token operator">::</span>process_data<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="2"></td><td><pre>  path <span class="token operator">=</span> <span class="token string">"mzxml_ms1_data/NEG"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="3"></td><td><pre>  polarity <span class="token operator">=</span> <span class="token string">"negative"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="4"></td><td><pre>  ppm <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="5"></td><td><pre>  peakwidth <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">60</span><span class="token punctuation">)</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="6"></td><td><pre>  threads <span class="token operator">=</span> <span class="token number">30</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="7"></td><td><pre>  output_tic <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="8"></td><td><pre>  output_bpc <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="9"></td><td><pre>  output_rt_correction_plot <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="10"></td><td><pre>  min_fraction <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="11"></td><td><pre>  group_for_figure <span class="token operator">=</span> <span class="token string">"QC"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="12"></td><td><pre>   snthresh <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="13"></td><td><pre>  prefilter <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">500</span><span class="token punctuation">)</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="14"></td><td><pre>  fitgauss <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="15"></td><td><pre>  integrate <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="16"></td><td><pre>  mzdiff <span class="token operator">=</span> <span class="token number">0.01</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="17"></td><td><pre>  noise <span class="token operator">=</span> <span class="token number">500</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="18"></td><td><pre>  binSize <span class="token operator">=</span> <span class="token number">0.025</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="19"></td><td><pre>  bw <span class="token operator">=</span> <span class="token number">5</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="20"></td><td><pre>  fill_peaks <span class="token operator">=</span> <span class="token boolean">FALSE</span></pre></td></tr><tr><td data-num="21"></td><td><pre><span class="token punctuation">)</span></pre></td></tr></table></figure><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 加载对象</span></pre></td></tr><tr><td data-num="2"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"mzxml_ms1_data/NEG/Result/object"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># 查看 metabolic features 数量</span></pre></td></tr><tr><td data-num="5"></td><td><pre>object</pre></td></tr></table></figure><h2 id="explore-data"><a class="anchor" href="#explore-data">#</a> Explore data</h2><p>将 peak table 和样本信息（元数据）整合，得到 <code>mass_dataset</code> class 对象。获取数据的总结信息。</p><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_0.png" alt="样本信息表示例 sample_info_pos.csv"></p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>library<span class="token punctuation">(</span>tidyverse<span class="token punctuation">)</span></pre></td></tr></table></figure><h3 id="正离子模式-2"><a class="anchor" href="#正离子模式-2">#</a> 正离子模式</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 加载对象</span></pre></td></tr><tr><td data-num="2"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"mzxml_ms1_data/POS/Result/object"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>object_pos <span class="token operator">&lt;-</span> object</pre></td></tr><tr><td data-num="4"></td><td><pre>object_pos</pre></td></tr><tr><td data-num="5"></td><td><pre></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token comment"># 读入样本信息</span></pre></td></tr><tr><td data-num="7"></td><td><pre>sample_info_pos <span class="token operator">&lt;-</span> readr<span class="token operator">::</span>read_csv<span class="token punctuation">(</span><span class="token string">"sample_info/sample_info_pos.csv"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token comment">#  查看 object_pos 中的元数据</span></pre></td></tr><tr><td data-num="10"></td><td><pre>object_pos <span class="token percent-operator operator">%>%</span>  extract_sample_info<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> head<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="11"></td><td><pre><span class="token comment">#>    sample_id group   class injection.order</span></pre></td></tr><tr><td data-num="12"></td><td><pre><span class="token comment">#> 1  sample_06  Case Subject               1</span></pre></td></tr><tr><td data-num="13"></td><td><pre><span class="token comment">#> 2 sample_103  Case Subject               2</span></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token comment">#> 3  sample_11  Case Subject               3</span></pre></td></tr><tr><td data-num="15"></td><td><pre><span class="token comment">#> 4 sample_112  Case Subject               4</span></pre></td></tr><tr><td data-num="16"></td><td><pre><span class="token comment">#> 5 sample_117  Case Subject               5</span></pre></td></tr><tr><td data-num="17"></td><td><pre><span class="token comment">#> 6  sample_12  Case Subject               6</span></pre></td></tr><tr><td data-num="18"></td><td><pre><span class="token comment">#?? 为何还没整合的情况下 object_pos 中就存在了部分元数据列？</span></pre></td></tr><tr><td data-num="19"></td><td><pre></pre></td></tr><tr><td data-num="20"></td><td><pre><span class="token comment"># 移除 object_pos 中的 "group", "class", "injection.order"</span></pre></td></tr><tr><td data-num="21"></td><td><pre>object_pos <span class="token operator">&lt;-</span> object_pos <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> dplyr<span class="token operator">::</span>select<span class="token punctuation">(</span><span class="token operator">-</span>c<span class="token punctuation">(</span><span class="token string">"group"</span><span class="token punctuation">,</span> <span class="token string">"class"</span><span class="token punctuation">,</span> <span class="token string">"injection.order"</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="22"></td><td><pre></pre></td></tr><tr><td data-num="23"></td><td><pre><span class="token comment"># 将 sample_info_pos 中的所有列整合到 object_pos 中</span></pre></td></tr><tr><td data-num="24"></td><td><pre>object_pos <span class="token operator">=</span> object_pos <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> left_join<span class="token punctuation">(</span>sample_info_pos<span class="token punctuation">,</span> by <span class="token operator">=</span> <span class="token string">"sample_id"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="25"></td><td><pre></pre></td></tr><tr><td data-num="26"></td><td><pre><span class="token comment"># 查看元数据信息</span></pre></td></tr><tr><td data-num="27"></td><td><pre>object_pos <span class="token percent-operator operator">%>%</span> extract_sample_info<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> head<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="28"></td><td><pre><span class="token comment">#>    sample_id injection.order   class batch  subject_id group</span></pre></td></tr><tr><td data-num="29"></td><td><pre><span class="token comment">#> 1  sample_06               4 Subject     1 subject_414  Case</span></pre></td></tr><tr><td data-num="30"></td><td><pre><span class="token comment">#> 2 sample_103              71 Subject     1 subject_330  Case</span></pre></td></tr><tr><td data-num="31"></td><td><pre><span class="token comment">#> 3  sample_11               6 Subject     1 subject_125  Case</span></pre></td></tr><tr><td data-num="32"></td><td><pre><span class="token comment">#> 4 sample_112              78 Subject     1 subject_295  Case</span></pre></td></tr><tr><td data-num="33"></td><td><pre><span class="token comment">#> 5 sample_117              80 Subject     1 subject_793  Case</span></pre></td></tr><tr><td data-num="34"></td><td><pre><span class="token comment">#> 6  sample_12               8 Subject     1 subject_387  Case</span></pre></td></tr><tr><td data-num="35"></td><td><pre></pre></td></tr><tr><td data-num="36"></td><td><pre><span class="token comment"># 保存数据</span></pre></td></tr><tr><td data-num="37"></td><td><pre>dir.create<span class="token punctuation">(</span><span class="token string">"data_cleaning/POS"</span><span class="token punctuation">,</span> showWarnings <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span> recursive <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="38"></td><td><pre>save<span class="token punctuation">(</span>object_pos<span class="token punctuation">,</span> file <span class="token operator">=</span> <span class="token string">"data_cleaning/POS/object_pos"</span><span class="token punctuation">)</span></pre></td></tr></table></figure><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 统计样本数和 variables 数</span></pre></td></tr><tr><td data-num="2"></td><td><pre>object_pos</pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># 根据 class 统计样本数量，可将 class 换成 group 或 batch 等</span></pre></td></tr><tr><td data-num="5"></td><td><pre>object_pos <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> dplyr<span class="token operator">::</span>count<span class="token punctuation">(</span>class<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># 获取 peak 分布图</span></pre></td></tr><tr><td data-num="8"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/POS/peak_distributation_plot_positive.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre>p<span class="token operator">&lt;-</span> object_pos <span class="token percent-operator operator">%>%</span> `<span class="token operator">+</span>`<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> log<span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> show_mz_rt_plot<span class="token punctuation">(</span>hex <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span> </pre></td></tr><tr><td data-num="11"></td><td><pre></pre></td></tr><tr><td data-num="12"></td><td><pre>p<span class="token operator">+</span> scale_size_continuous<span class="token punctuation">(</span>range <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">0.01</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="13"></td><td><pre></pre></td></tr><tr><td data-num="14"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="15"></td><td><pre></pre></td></tr><tr><td data-num="16"></td><td><pre><span class="token comment"># 查看总缺失值数量</span></pre></td></tr><tr><td data-num="17"></td><td><pre>get_mv_number<span class="token punctuation">(</span>object <span class="token operator">=</span> object_pos<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="18"></td><td><pre><span class="token comment">#[1] 786005</span></pre></td></tr><tr><td data-num="19"></td><td><pre></pre></td></tr><tr><td data-num="20"></td><td><pre><span class="token comment"># 查看各样本内的缺失值</span></pre></td></tr><tr><td data-num="21"></td><td><pre>get_mv_number<span class="token punctuation">(</span>object <span class="token operator">=</span> object_pos<span class="token punctuation">,</span> by <span class="token operator">=</span> <span class="token string">"sample"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> head<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="22"></td><td><pre><span class="token comment"># sample_06 sample_103  sample_11 sample_112 sample_117  sample_12</span></pre></td></tr><tr><td data-num="23"></td><td><pre><span class="token comment">#      4017       2713       4064       2981       2920       3846</span></pre></td></tr><tr><td data-num="24"></td><td><pre></pre></td></tr><tr><td data-num="25"></td><td><pre><span class="token comment"># 查看各 variable 的缺失值</span></pre></td></tr><tr><td data-num="26"></td><td><pre>get_mv_number<span class="token punctuation">(</span>object <span class="token operator">=</span> object_pos<span class="token punctuation">,</span> by <span class="token operator">=</span> <span class="token string">"variable"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> head<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="27"></td><td><pre><span class="token comment">#M70T73_POS  M70T53_POS M70T183_POS M70T527_POS M71T695_POS M71T183_POS</span></pre></td></tr><tr><td data-num="28"></td><td><pre><span class="token comment">#        129          16         155          54         133         169</span></pre></td></tr><tr><td data-num="29"></td><td><pre></pre></td></tr><tr><td data-num="30"></td><td><pre><span class="token comment"># 绘图展示缺失值信息，可在下一节生成</span></pre></td></tr><tr><td data-num="31"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/POS/total_MVs.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="32"></td><td><pre></pre></td></tr><tr><td data-num="33"></td><td><pre>show_missing_values<span class="token punctuation">(</span>object <span class="token operator">=</span> object_pos<span class="token punctuation">,</span> show_column_names <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> show_row_names <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> percentage <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="34"></td><td><pre></pre></td></tr><tr><td data-num="35"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="36"></td><td><pre></pre></td></tr><tr><td data-num="37"></td><td><pre><span class="token comment"># 绘图展示各样本缺失值信息，可在下一节生成</span></pre></td></tr><tr><td data-num="38"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/POS/Samples_MVs.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="39"></td><td><pre></pre></td></tr><tr><td data-num="40"></td><td><pre>show_sample_missing_values<span class="token punctuation">(</span>object <span class="token operator">=</span> object_pos<span class="token punctuation">,</span> percentage <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> color_by <span class="token operator">=</span> <span class="token string">"class"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="41"></td><td><pre></pre></td></tr><tr><td data-num="42"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="43"></td><td><pre></pre></td></tr><tr><td data-num="44"></td><td><pre><span class="token comment"># 绘图展示各 variables 缺失值信息，可在下一节生成</span></pre></td></tr><tr><td data-num="45"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/POS/Variables_MVs.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="46"></td><td><pre></pre></td></tr><tr><td data-num="47"></td><td><pre>p<span class="token operator">&lt;-</span> show_variable_missing_values<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="48"></td><td><pre>  object <span class="token operator">=</span> object_pos<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="49"></td><td><pre>  percentage <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="50"></td><td><pre>  show_x_text <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="51"></td><td><pre>  show_x_ticks <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="52"></td><td><pre>  color_by <span class="token operator">=</span> <span class="token string">"mz"</span></pre></td></tr><tr><td data-num="53"></td><td><pre><span class="token punctuation">)</span> </pre></td></tr><tr><td data-num="54"></td><td><pre></pre></td></tr><tr><td data-num="55"></td><td><pre>p<span class="token operator">+</span> scale_size_continuous<span class="token punctuation">(</span>range <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">0.01</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="56"></td><td><pre></pre></td></tr><tr><td data-num="57"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr></table></figure><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_4.png" alt="峰分布图"></p><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_5.svg" alt="各variable的缺失值数量"><br>黑色代表缺失值。</p><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_6.svg" alt="各样本的缺失值比例"></p><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_7.svg" alt="各variable的缺失值比例"></p><h3 id="负离子模式-2"><a class="anchor" href="#负离子模式-2">#</a> 负离子模式</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 加载对象</span></pre></td></tr><tr><td data-num="2"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"mzxml_ms1_data/NEG/Result/object"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>object_neg <span class="token operator">&lt;-</span> object</pre></td></tr><tr><td data-num="4"></td><td><pre>object_neg</pre></td></tr><tr><td data-num="5"></td><td><pre></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token comment"># 读入样本信息</span></pre></td></tr><tr><td data-num="7"></td><td><pre>sample_info_neg <span class="token operator">&lt;-</span> readr<span class="token operator">::</span>read_csv<span class="token punctuation">(</span><span class="token string">"sample_info/sample_info_neg.csv"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre></pre></td></tr><tr><td data-num="9"></td><td><pre>object_neg <span class="token percent-operator operator">%>%</span>  extract_sample_info<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> head<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="10"></td><td><pre><span class="token comment">#   sample_id group   class injection.order</span></pre></td></tr><tr><td data-num="11"></td><td><pre><span class="token comment">#1  sample_06  Case Subject               1</span></pre></td></tr><tr><td data-num="12"></td><td><pre><span class="token comment">#2 sample_103  Case Subject               2</span></pre></td></tr><tr><td data-num="13"></td><td><pre><span class="token comment">#3  sample_11  Case Subject               3</span></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token comment">#4 sample_112  Case Subject               4</span></pre></td></tr><tr><td data-num="15"></td><td><pre><span class="token comment">#5 sample_117  Case Subject               5</span></pre></td></tr><tr><td data-num="16"></td><td><pre><span class="token comment">#6  sample_12  Case Subject               6</span></pre></td></tr><tr><td data-num="17"></td><td><pre></pre></td></tr><tr><td data-num="18"></td><td><pre>object_neg <span class="token operator">&lt;-</span> object_neg <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> dplyr<span class="token operator">::</span>select<span class="token punctuation">(</span><span class="token operator">-</span>c<span class="token punctuation">(</span><span class="token string">"group"</span><span class="token punctuation">,</span> <span class="token string">"class"</span><span class="token punctuation">,</span> <span class="token string">"injection.order"</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="19"></td><td><pre></pre></td></tr><tr><td data-num="20"></td><td><pre><span class="token comment"># 将 sample_info_neg 添加至 object_neg</span></pre></td></tr><tr><td data-num="21"></td><td><pre>object_neg <span class="token operator">=</span> object_neg <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> left_join<span class="token punctuation">(</span>sample_info_neg<span class="token punctuation">,</span> by <span class="token operator">=</span> <span class="token string">"sample_id"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="22"></td><td><pre></pre></td></tr><tr><td data-num="23"></td><td><pre>object_neg <span class="token percent-operator operator">%>%</span> extract_sample_info<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> head<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="24"></td><td><pre><span class="token comment">#   sample_id injection.order   class batch  subject_id group</span></pre></td></tr><tr><td data-num="25"></td><td><pre><span class="token comment">#1  sample_06               4 Subject     1 subject_414  Case</span></pre></td></tr><tr><td data-num="26"></td><td><pre><span class="token comment">#2 sample_103              71 Subject     1 subject_330  Case</span></pre></td></tr><tr><td data-num="27"></td><td><pre><span class="token comment">#3  sample_11               6 Subject     1 subject_125  Case</span></pre></td></tr><tr><td data-num="28"></td><td><pre><span class="token comment">#4 sample_112              78 Subject     1 subject_295  Case</span></pre></td></tr><tr><td data-num="29"></td><td><pre><span class="token comment">#5 sample_117              80 Subject     1 subject_793  Case</span></pre></td></tr><tr><td data-num="30"></td><td><pre><span class="token comment">#6  sample_12               8 Subject     1 subject_387  Case</span></pre></td></tr><tr><td data-num="31"></td><td><pre></pre></td></tr><tr><td data-num="32"></td><td><pre><span class="token comment"># 保存数据</span></pre></td></tr><tr><td data-num="33"></td><td><pre>dir.create<span class="token punctuation">(</span><span class="token string">"data_cleaning/NEG"</span><span class="token punctuation">,</span> showWarnings <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span> recursive <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="34"></td><td><pre>save<span class="token punctuation">(</span>object_neg<span class="token punctuation">,</span> file <span class="token operator">=</span> <span class="token string">"data_cleaning/NEG/object_neg"</span><span class="token punctuation">)</span></pre></td></tr></table></figure><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 统计样本数和 variables 数</span></pre></td></tr><tr><td data-num="2"></td><td><pre>object_neg</pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment"># 根据 class 统计样本数量，可将 class 换成 group 或 batch 等</span></pre></td></tr><tr><td data-num="5"></td><td><pre>object_neg <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> dplyr<span class="token operator">::</span>count<span class="token punctuation">(</span>class<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># 获取 peak 分布图</span></pre></td></tr><tr><td data-num="8"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/NEG/peak_distributation_plot_negtive.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre>object_neg <span class="token percent-operator operator">%>%</span> `<span class="token operator">+</span>`<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> log<span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> show_mz_rt_plot<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> scale_size_continuous<span class="token punctuation">(</span>range <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">0.01</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="11"></td><td><pre></pre></td></tr><tr><td data-num="12"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="13"></td><td><pre></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token comment"># 查看总缺失值数量</span></pre></td></tr><tr><td data-num="15"></td><td><pre>get_mv_number<span class="token punctuation">(</span>object <span class="token operator">=</span> object_neg<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="16"></td><td><pre><span class="token comment">#[1] 748237</span></pre></td></tr><tr><td data-num="17"></td><td><pre></pre></td></tr><tr><td data-num="18"></td><td><pre><span class="token comment"># 查看各样本内的缺失值</span></pre></td></tr><tr><td data-num="19"></td><td><pre>get_mv_number<span class="token punctuation">(</span>object <span class="token operator">=</span> object_neg<span class="token punctuation">,</span> by <span class="token operator">=</span> <span class="token string">"sample"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> head<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="20"></td><td><pre><span class="token comment"># sample_06 sample_103  sample_11 sample_112 sample_117  sample_12</span></pre></td></tr><tr><td data-num="21"></td><td><pre><span class="token comment">#      3029       2766       3298       3100       2912       3053</span></pre></td></tr><tr><td data-num="22"></td><td><pre></pre></td></tr><tr><td data-num="23"></td><td><pre><span class="token comment"># 查看各 variable 的缺失值</span></pre></td></tr><tr><td data-num="24"></td><td><pre>get_mv_number<span class="token punctuation">(</span>object <span class="token operator">=</span> object_neg<span class="token punctuation">,</span> by <span class="token operator">=</span> <span class="token string">"variable"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> head<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="25"></td><td><pre><span class="token comment">#M70T712_NEG M70T527_NEG M70T587_NEG  M70T47_NEG M71T587_NEG M71T641_NEG</span></pre></td></tr><tr><td data-num="26"></td><td><pre><span class="token comment">#         16         137           2         146          41          19</span></pre></td></tr><tr><td data-num="27"></td><td><pre></pre></td></tr><tr><td data-num="28"></td><td><pre><span class="token comment"># 绘图展示缺失值信息，可在下一节生成</span></pre></td></tr><tr><td data-num="29"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/NEG/total_MVs.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="30"></td><td><pre></pre></td></tr><tr><td data-num="31"></td><td><pre>show_missing_values<span class="token punctuation">(</span>object <span class="token operator">=</span> object_neg<span class="token punctuation">,</span> show_column_names <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span> percentage <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="32"></td><td><pre></pre></td></tr><tr><td data-num="33"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="34"></td><td><pre></pre></td></tr><tr><td data-num="35"></td><td><pre><span class="token comment"># 绘图展示各样本缺失值信息，可在下一节生成</span></pre></td></tr><tr><td data-num="36"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/NEG/Samples_MVs.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="37"></td><td><pre></pre></td></tr><tr><td data-num="38"></td><td><pre>show_sample_missing_values<span class="token punctuation">(</span>object <span class="token operator">=</span> object_neg<span class="token punctuation">,</span> percentage <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="39"></td><td><pre></pre></td></tr><tr><td data-num="40"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="41"></td><td><pre></pre></td></tr><tr><td data-num="42"></td><td><pre><span class="token comment"># 绘图展示各 variables 缺失值信息，可在下一节生成</span></pre></td></tr><tr><td data-num="43"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/NEG/Variables_MVs.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="44"></td><td><pre></pre></td></tr><tr><td data-num="45"></td><td><pre>p<span class="token operator">&lt;-</span> show_variable_missing_values<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="46"></td><td><pre>  object <span class="token operator">=</span> object_neg<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="47"></td><td><pre>  percentage <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="48"></td><td><pre>  show_x_text <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="49"></td><td><pre>  show_x_ticks <span class="token operator">=</span> <span class="token boolean">FALSE</span></pre></td></tr><tr><td data-num="50"></td><td><pre><span class="token punctuation">)</span> </pre></td></tr><tr><td data-num="51"></td><td><pre></pre></td></tr><tr><td data-num="52"></td><td><pre>p<span class="token operator">+</span> scale_size_continuous<span class="token punctuation">(</span>range <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">0.01</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="53"></td><td><pre></pre></td></tr><tr><td data-num="54"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr></table></figure><h2 id="数据清洗data-cleaning"><a class="anchor" href="#数据清洗data-cleaning">#</a> 数据清洗（Data cleaning）</h2><h3 id="查看质量"><a class="anchor" href="#查看质量">#</a> 查看质量</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 加载数据</span></pre></td></tr><tr><td data-num="2"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"data_cleaning/POS/object_pos"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"data_cleaning/NEG/object_neg"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># 将批次号改为字符串</span></pre></td></tr><tr><td data-num="6"></td><td><pre>object_pos <span class="token operator">&lt;-</span> object_pos <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> dplyr<span class="token operator">::</span>mutate<span class="token punctuation">(</span>batch <span class="token operator">=</span> as.character<span class="token punctuation">(</span>batch<span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre>object_neg <span class="token operator">&lt;-</span> object_neg <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> dplyr<span class="token operator">::</span>mutate<span class="token punctuation">(</span>batch <span class="token operator">=</span> as.character<span class="token punctuation">(</span>batch<span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre><span class="token comment"># 先评估数据质量</span></pre></td></tr><tr><td data-num="11"></td><td><pre>massqc<span class="token operator">::</span>massqc_report<span class="token punctuation">(</span>object <span class="token operator">=</span> object_pos<span class="token punctuation">,</span> path <span class="token operator">=</span> <span class="token string">"data_cleaning/POS/data_quality_before_data_cleaning"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre></pre></td></tr><tr><td data-num="13"></td><td><pre>massqc<span class="token operator">::</span>massqc_report<span class="token punctuation">(</span>object <span class="token operator">=</span> object_neg<span class="token punctuation">,</span> path <span class="token operator">=</span> <span class="token string">"data_cleaning/NEG/data_quality_before_data_cleaning"</span><span class="token punctuation">)</span></pre></td></tr></table></figure><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_8.png" alt="正离子PCA"></p><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_9.png" alt="负离子PCA"><br><font color="#FF0000">从上两图可看出正离子模式下存在严重的批次效应，负离子模式下不存在明显的批次效应。</font></p><h3 id="开始清洗"><a class="anchor" href="#开始清洗">#</a> 开始清洗</h3><h4 id="移除噪音代谢features缺失值过滤"><a class="anchor" href="#移除噪音代谢features缺失值过滤">#</a> 移除噪音代谢 features—— 缺失值过滤。</h4><p>移除超过 20% QC 样本中含有 MVs 以及至少在 50% 实验组或对照组样本中含有 MVs 的 variables。</p><ul><li><p>正离子模式</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 查看各分组样本量</span></pre></td></tr><tr><td data-num="2"></td><td><pre>object_pos <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> dplyr<span class="token operator">::</span>count<span class="token punctuation">(</span>group<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment">#>     group   n</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment">#> 1    Case 110</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment">#> 2 Control 110</span></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token comment">#> 3      QC  39</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># QC 样本中的 MV 占比</span></pre></td></tr><tr><td data-num="9"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/POS/MVpercentQC.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="10"></td><td><pre></pre></td></tr><tr><td data-num="11"></td><td><pre>p<span class="token operator">&lt;-</span> show_variable_missing_values<span class="token punctuation">(</span>object <span class="token operator">=</span> object_pos <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>class <span class="token operator">==</span> <span class="token string">"QC"</span><span class="token punctuation">)</span><span class="token punctuation">,</span> percentage <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span> </pre></td></tr><tr><td data-num="12"></td><td><pre></pre></td></tr><tr><td data-num="13"></td><td><pre>p<span class="token operator">+</span> scale_size_continuous<span class="token punctuation">(</span>range <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">0.01</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="14"></td><td><pre></pre></td></tr><tr><td data-num="15"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="16"></td><td><pre></pre></td></tr><tr><td data-num="17"></td><td><pre><span class="token comment"># 统计 QC 中的 MV 占比</span></pre></td></tr><tr><td data-num="18"></td><td><pre>qc_id <span class="token operator">=</span> object_pos <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>class <span class="token operator">==</span> <span class="token string">"QC"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> pull<span class="token punctuation">(</span>sample_id<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="19"></td><td><pre></pre></td></tr><tr><td data-num="20"></td><td><pre><span class="token comment"># 统计对照组中的 MV 占比</span></pre></td></tr><tr><td data-num="21"></td><td><pre>control_id <span class="token operator">=</span> object_pos <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>group <span class="token operator">==</span> <span class="token string">"Control"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> pull<span class="token punctuation">(</span>sample_id<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="22"></td><td><pre></pre></td></tr><tr><td data-num="23"></td><td><pre><span class="token comment"># 统计实验组中的 MV 占比</span></pre></td></tr><tr><td data-num="24"></td><td><pre>case_id <span class="token operator">=</span> object_pos <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>group <span class="token operator">==</span> <span class="token string">"Case"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> pull<span class="token punctuation">(</span>sample_id<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="25"></td><td><pre></pre></td></tr><tr><td data-num="26"></td><td><pre><span class="token comment"># 整合以上统计信息</span></pre></td></tr><tr><td data-num="27"></td><td><pre>object_pos <span class="token operator">=</span> object_pos <span class="token percent-operator operator">%>%</span> mutate_variable_na_freq<span class="token punctuation">(</span>according_to_samples <span class="token operator">=</span> qc_id<span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> mutate_variable_na_freq<span class="token punctuation">(</span>according_to_samples <span class="token operator">=</span> control_id<span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> mutate_variable_na_freq<span class="token punctuation">(</span>according_to_samples <span class="token operator">=</span> case_id<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="28"></td><td><pre></pre></td></tr><tr><td data-num="29"></td><td><pre>head<span class="token punctuation">(</span>extract_variable_info<span class="token punctuation">(</span>object_pos<span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="30"></td><td><pre><span class="token comment">#variable_id       mz        rt    na_freq na_freq.1 na_freq.2</span></pre></td></tr><tr><td data-num="31"></td><td><pre><span class="token comment">#1  M70T73_POS 70.04074  73.31705 0.28205128 0.6000000 0.4727273</span></pre></td></tr><tr><td data-num="32"></td><td><pre><span class="token comment">#2  M70T53_POS 70.06596  52.78542 0.00000000 0.1454545 0.0000000</span></pre></td></tr><tr><td data-num="33"></td><td><pre><span class="token comment">#3 M70T183_POS 70.19977 182.87981 0.00000000 0.6636364 0.7454545</span></pre></td></tr><tr><td data-num="34"></td><td><pre><span class="token comment">#4 M70T527_POS 70.36113 526.76657 0.02564103 0.1818182 0.3000000</span></pre></td></tr><tr><td data-num="35"></td><td><pre><span class="token comment">#5 M71T695_POS 70.56911 694.84592 0.02564103 0.6454545 0.5545455</span></pre></td></tr><tr><td data-num="36"></td><td><pre><span class="token comment">#6 M71T183_POS 70.75034 182.77790 0.05128205 0.7272727 0.7909091</span></pre></td></tr><tr><td data-num="37"></td><td><pre></pre></td></tr><tr><td data-num="38"></td><td><pre><span class="token comment"># 移除 variables</span></pre></td></tr><tr><td data-num="39"></td><td><pre>object_pos <span class="token operator">&lt;-</span> object_pos <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"variable_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>na_freq <span class="token operator">&lt;</span> <span class="token number">0.2</span> <span class="token operator">&amp;</span> <span class="token punctuation">(</span>na_freq.<span class="token number">1</span> <span class="token operator">&lt;</span> <span class="token number">0.5</span> <span class="token operator">|</span> na_freq.<span class="token number">2</span> <span class="token operator">&lt;</span> <span class="token number">0.5</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="40"></td><td><pre></pre></td></tr><tr><td data-num="41"></td><td><pre>object_pos</pre></td></tr></table></figure><p><strong>注</strong>：na_freq、na_freq.1 和 na_freq.2 在此处分别代表某 variables 在 QC 样本、对照组样本和实验组样本中缺失值 MV 所占的百分比。</p><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_19.png" alt="MVpercentQC"></p></li><li><p>负离子模式</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 查看各分组样本量</span></pre></td></tr><tr><td data-num="2"></td><td><pre>object_neg <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> dplyr<span class="token operator">::</span>count<span class="token punctuation">(</span>group<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment">#>     group   n</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment">#> 1    Case 110</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment">#> 2 Control 110</span></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token comment">#> 3      QC  39</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># QC 样本中的 MV 占比</span></pre></td></tr><tr><td data-num="9"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/NEG/MVpercentQC.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="10"></td><td><pre></pre></td></tr><tr><td data-num="11"></td><td><pre>p<span class="token operator">&lt;-</span> show_variable_missing_values<span class="token punctuation">(</span>object <span class="token operator">=</span> object_neg <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>class <span class="token operator">==</span> <span class="token string">"QC"</span><span class="token punctuation">)</span><span class="token punctuation">,</span> percentage <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre></pre></td></tr><tr><td data-num="13"></td><td><pre>p<span class="token operator">+</span> scale_size_continuous<span class="token punctuation">(</span>range <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">0.01</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="14"></td><td><pre></pre></td></tr><tr><td data-num="15"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="16"></td><td><pre></pre></td></tr><tr><td data-num="17"></td><td><pre><span class="token comment"># 统计 QC 中的 MV 占比</span></pre></td></tr><tr><td data-num="18"></td><td><pre>qc_id <span class="token operator">=</span> object_neg <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>class <span class="token operator">==</span> <span class="token string">"QC"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> pull<span class="token punctuation">(</span>sample_id<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="19"></td><td><pre></pre></td></tr><tr><td data-num="20"></td><td><pre><span class="token comment"># 统计对照组中的 MV 占比</span></pre></td></tr><tr><td data-num="21"></td><td><pre>control_id <span class="token operator">=</span> object_neg <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>group <span class="token operator">==</span> <span class="token string">"Control"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> pull<span class="token punctuation">(</span>sample_id<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="22"></td><td><pre></pre></td></tr><tr><td data-num="23"></td><td><pre><span class="token comment"># 统计实验组中的 MV 占比</span></pre></td></tr><tr><td data-num="24"></td><td><pre>case_id <span class="token operator">=</span> object_neg <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>group <span class="token operator">==</span> <span class="token string">"Case"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> pull<span class="token punctuation">(</span>sample_id<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="25"></td><td><pre></pre></td></tr><tr><td data-num="26"></td><td><pre><span class="token comment"># 整合以上统计信息</span></pre></td></tr><tr><td data-num="27"></td><td><pre>object_neg <span class="token operator">=</span> object_neg <span class="token percent-operator operator">%>%</span> mutate_variable_na_freq<span class="token punctuation">(</span>according_to_samples <span class="token operator">=</span> qc_id<span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> mutate_variable_na_freq<span class="token punctuation">(</span>according_to_samples <span class="token operator">=</span> control_id<span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> mutate_variable_na_freq<span class="token punctuation">(</span>according_to_samples <span class="token operator">=</span> case_id<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="28"></td><td><pre></pre></td></tr><tr><td data-num="29"></td><td><pre>head<span class="token punctuation">(</span>extract_variable_info<span class="token punctuation">(</span>object_neg<span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="30"></td><td><pre><span class="token comment">#variable_id       mz        rt    na_freq na_freq.1 na_freq.2</span></pre></td></tr><tr><td data-num="31"></td><td><pre><span class="token comment">#1 M70T712_NEG 70.05911 711.97894 0.05128205 0.109090909 0.018181818</span></pre></td></tr><tr><td data-num="32"></td><td><pre><span class="token comment">#2 M70T527_NEG 70.13902 526.85416 0.33333333 0.509090909 0.618181818</span></pre></td></tr><tr><td data-num="33"></td><td><pre><span class="token comment">#3 M70T587_NEG 70.31217 587.25330 0.00000000 0.009090909 0.009090909</span></pre></td></tr><tr><td data-num="34"></td><td><pre><span class="token comment">#4  M70T47_NEG 70.33835  46.57537 0.84615385 0.936363636 0.090909091</span></pre></td></tr><tr><td data-num="35"></td><td><pre><span class="token comment">#5 M71T587_NEG 70.56315 587.02570 0.17948718 0.145454545 0.163636364</span></pre></td></tr><tr><td data-num="36"></td><td><pre><span class="token comment">#6 M71T641_NEG 70.70657 641.16672 0.10256410 0.063636364 0.072727273</span></pre></td></tr><tr><td data-num="37"></td><td><pre></pre></td></tr><tr><td data-num="38"></td><td><pre><span class="token comment"># 移除 variables</span></pre></td></tr><tr><td data-num="39"></td><td><pre>object_neg <span class="token operator">&lt;-</span> object_neg <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"variable_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>na_freq <span class="token operator">&lt;</span> <span class="token number">0.2</span> <span class="token operator">&amp;</span> <span class="token punctuation">(</span>na_freq.<span class="token number">1</span> <span class="token operator">&lt;</span> <span class="token number">0.5</span> <span class="token operator">|</span> na_freq.<span class="token number">2</span> <span class="token operator">&lt;</span> <span class="token number">0.5</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="40"></td><td><pre></pre></td></tr><tr><td data-num="41"></td><td><pre>object_neg</pre></td></tr></table></figure></li></ul><h4 id="过滤离群样本filter-outlier-samples"><a class="anchor" href="#过滤离群样本filter-outlier-samples">#</a> 过滤离群样本（Filter outlier samples）</h4><ul><li><p>正离子模式</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 总览</span></pre></td></tr><tr><td data-num="2"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/POS/MVpercentALL.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre>massdataset<span class="token operator">::</span>show_sample_missing_values<span class="token punctuation">(</span>object <span class="token operator">=</span> object_pos<span class="token punctuation">,</span> color_by <span class="token operator">=</span> <span class="token string">"group"</span><span class="token punctuation">,</span> order_by <span class="token operator">=</span> <span class="token string">"injection.order"</span><span class="token punctuation">,</span> percentage <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span> <span class="token operator">+</span> theme<span class="token punctuation">(</span>axis.text.x <span class="token operator">=</span> element_text<span class="token punctuation">(</span>size <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">+</span> scale_size_continuous<span class="token punctuation">(</span>range <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">0.1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">+</span> ggsci<span class="token operator">::</span>scale_color_aaas<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre></pre></td></tr><tr><td data-num="6"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># 检测离群样本</span></pre></td></tr><tr><td data-num="9"></td><td><pre>outlier_samples <span class="token operator">=</span> object_pos <span class="token percent-operator operator">%>%</span> `<span class="token operator">+</span>`<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> log<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> scale<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> detect_outlier<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="10"></td><td><pre></pre></td></tr><tr><td data-num="11"></td><td><pre>outlier_samples</pre></td></tr><tr><td data-num="12"></td><td><pre><span class="token comment">#--------------------</span></pre></td></tr><tr><td data-num="13"></td><td><pre><span class="token comment">#masscleaner</span></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token comment">#--------------------</span></pre></td></tr><tr><td data-num="15"></td><td><pre><span class="token comment">#1 according_to_na : 0 outlier samples.</span></pre></td></tr><tr><td data-num="16"></td><td><pre><span class="token comment">#2 according_to_pc_sd : 0 outlier samples.</span></pre></td></tr><tr><td data-num="17"></td><td><pre><span class="token comment">#3 according_to_pc_mad : 0 outlier samples.</span></pre></td></tr><tr><td data-num="18"></td><td><pre><span class="token comment">#4 accordint_to_distance : 0 outlier samples.</span></pre></td></tr><tr><td data-num="19"></td><td><pre><span class="token comment">#4 accordint_to_distance : 0 outlier samples.</span></pre></td></tr><tr><td data-num="20"></td><td><pre><span class="token comment">#extract all outlier table using extract_outlier_table()</span></pre></td></tr><tr><td data-num="21"></td><td><pre></pre></td></tr><tr><td data-num="22"></td><td><pre>outlier_table <span class="token operator">&lt;-</span> extract_outlier_table<span class="token punctuation">(</span>outlier_samples<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="23"></td><td><pre></pre></td></tr><tr><td data-num="24"></td><td><pre>outlier_table <span class="token percent-operator operator">%>%</span> head<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="25"></td><td><pre><span class="token comment">#           according_to_na pc_sd pc_mad accordint_to_distance</span></pre></td></tr><tr><td data-num="26"></td><td><pre><span class="token comment">#sample_06            FALSE FALSE  FALSE                 FALSE</span></pre></td></tr><tr><td data-num="27"></td><td><pre><span class="token comment">#sample_103           FALSE FALSE  FALSE                 FALSE</span></pre></td></tr><tr><td data-num="28"></td><td><pre><span class="token comment">#sample_11            FALSE FALSE  FALSE                 FALSE</span></pre></td></tr><tr><td data-num="29"></td><td><pre><span class="token comment">#sample_112           FALSE FALSE  FALSE                 FALSE</span></pre></td></tr><tr><td data-num="30"></td><td><pre><span class="token comment">#sample_117           FALSE FALSE  FALSE                 FALSE</span></pre></td></tr><tr><td data-num="31"></td><td><pre><span class="token comment">#sample_12            FALSE FALSE  FALSE                 FALSE</span></pre></td></tr><tr><td data-num="32"></td><td><pre></pre></td></tr><tr><td data-num="33"></td><td><pre>outlier_table <span class="token percent-operator operator">%>%</span> apply<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span><span class="token punctuation">&#123;</span> sum<span class="token punctuation">(</span>x<span class="token punctuation">)</span>  <span class="token punctuation">&#125;</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> `<span class="token operator">></span>`<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> which<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="34"></td><td><pre><span class="token comment"># #named integer(0)</span></pre></td></tr><tr><td data-num="35"></td><td><pre><span class="token comment">## 无离群样本</span></pre></td></tr></table></figure><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 删除离群样本，如果有的话</span></pre></td></tr><tr><td data-num="2"></td><td><pre>need_id_pos <span class="token operator">&lt;-</span> names<span class="token punctuation">(</span>outlier_table <span class="token percent-operator operator">%>%</span> apply<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span><span class="token punctuation">&#123;</span> sum<span class="token punctuation">(</span>x<span class="token punctuation">)</span>  <span class="token punctuation">&#125;</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> `<span class="token operator">==</span>`<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> which<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre>object_pos <span class="token operator">&lt;-</span> object_pos <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>sample_id <span class="token percent-operator operator">%in%</span> need_id_pos<span class="token punctuation">)</span></pre></td></tr></table></figure><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_20.png" alt="MVpercentALL"></p></li><li><p>负离子模式</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 总览</span></pre></td></tr><tr><td data-num="2"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/NEG/MVpercentALL.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre>p<span class="token operator">&lt;-</span> massdataset<span class="token operator">::</span>show_sample_missing_values<span class="token punctuation">(</span>object <span class="token operator">=</span> object_neg<span class="token punctuation">,</span> color_by <span class="token operator">=</span> <span class="token string">"group"</span><span class="token punctuation">,</span> order_by <span class="token operator">=</span> <span class="token string">"injection.order"</span><span class="token punctuation">,</span> percentage <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre></pre></td></tr><tr><td data-num="6"></td><td><pre>p<span class="token operator">+</span> theme<span class="token punctuation">(</span>axis.text.x <span class="token operator">=</span> element_text<span class="token punctuation">(</span>size <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">+</span> scale_size_continuous<span class="token punctuation">(</span>range <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token number">0.1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">+</span> ggsci<span class="token operator">::</span>scale_color_aaas<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre><span class="token comment"># 检测离群样本</span></pre></td></tr><tr><td data-num="11"></td><td><pre>outlier_samples <span class="token operator">=</span> object_neg <span class="token percent-operator operator">%>%</span> `<span class="token operator">+</span>`<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> log<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> scale<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> detect_outlier<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre></pre></td></tr><tr><td data-num="13"></td><td><pre>outlier_samples</pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token comment">#--------------------</span></pre></td></tr><tr><td data-num="15"></td><td><pre><span class="token comment">#masscleaner</span></pre></td></tr><tr><td data-num="16"></td><td><pre><span class="token comment">#--------------------</span></pre></td></tr><tr><td data-num="17"></td><td><pre><span class="token comment">#1 according_to_na : 0 outlier samples.</span></pre></td></tr><tr><td data-num="18"></td><td><pre><span class="token comment">#2 according_to_pc_sd : 0 outlier samples.</span></pre></td></tr><tr><td data-num="19"></td><td><pre><span class="token comment">#3 according_to_pc_mad : 0 outlier samples.</span></pre></td></tr><tr><td data-num="20"></td><td><pre><span class="token comment">#4 accordint_to_distance : 0 outlier samples.</span></pre></td></tr><tr><td data-num="21"></td><td><pre><span class="token comment">#4 accordint_to_distance : 0 outlier samples.</span></pre></td></tr><tr><td data-num="22"></td><td><pre><span class="token comment">#extract all outlier table using extract_outlier_table()</span></pre></td></tr><tr><td data-num="23"></td><td><pre></pre></td></tr><tr><td data-num="24"></td><td><pre>outlier_table <span class="token operator">&lt;-</span> extract_outlier_table<span class="token punctuation">(</span>outlier_samples<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="25"></td><td><pre></pre></td></tr><tr><td data-num="26"></td><td><pre>outlier_table <span class="token percent-operator operator">%>%</span> head<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="27"></td><td><pre><span class="token comment">#           according_to_na pc_sd pc_mad accordint_to_distance</span></pre></td></tr><tr><td data-num="28"></td><td><pre><span class="token comment">#sample_06            FALSE FALSE  FALSE                 FALSE</span></pre></td></tr><tr><td data-num="29"></td><td><pre><span class="token comment">#sample_103           FALSE FALSE  FALSE                 FALSE</span></pre></td></tr><tr><td data-num="30"></td><td><pre><span class="token comment">#sample_11            FALSE FALSE  FALSE                 FALSE</span></pre></td></tr><tr><td data-num="31"></td><td><pre><span class="token comment">#sample_112           FALSE FALSE  FALSE                 FALSE</span></pre></td></tr><tr><td data-num="32"></td><td><pre><span class="token comment">#sample_117           FALSE FALSE  FALSE                 FALSE</span></pre></td></tr><tr><td data-num="33"></td><td><pre><span class="token comment">#sample_12            FALSE FALSE  FALSE                 FALSE</span></pre></td></tr><tr><td data-num="34"></td><td><pre></pre></td></tr><tr><td data-num="35"></td><td><pre>outlier_table <span class="token percent-operator operator">%>%</span> apply<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span><span class="token punctuation">&#123;</span> sum<span class="token punctuation">(</span>x<span class="token punctuation">)</span>  <span class="token punctuation">&#125;</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> `<span class="token operator">></span>`<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> which<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="36"></td><td><pre><span class="token comment"># #named integer(0)</span></pre></td></tr><tr><td data-num="37"></td><td><pre><span class="token comment">## 无离群样本</span></pre></td></tr></table></figure></li></ul><h2 id="缺失值填充missing-value-imputation"><a class="anchor" href="#缺失值填充missing-value-imputation">#</a> 缺失值填充（Missing value imputation）</h2><p>对原始数据中的缺失值进行模拟（missing value recoding）。方法包括：&quot;knn&quot;, &quot;rf&quot; (missForest), &quot;mean&quot;, &quot;median&quot;, &quot;zero&quot;, &quot;minimum&quot;, &quot;bpca&quot;, &quot;svdImpute&quot;, &quot;ppca&quot;。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 获取正离子模式下的 MV 数量</span></pre></td></tr><tr><td data-num="2"></td><td><pre>get_mv_number<span class="token punctuation">(</span>object_pos<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment">#> [1] 148907</span></pre></td></tr><tr><td data-num="4"></td><td><pre></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># 填充正离子模式缺失值</span></pre></td></tr><tr><td data-num="6"></td><td><pre>object_pos <span class="token operator">&lt;-</span> impute_mv<span class="token punctuation">(</span>object <span class="token operator">=</span> object_pos<span class="token punctuation">,</span> method <span class="token operator">=</span> <span class="token string">"knn"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># 获取正离子模式下填充后的 MV 数量</span></pre></td></tr><tr><td data-num="9"></td><td><pre>get_mv_number<span class="token punctuation">(</span>object_pos<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="10"></td><td><pre><span class="token comment">#> [1] 0</span></pre></td></tr><tr><td data-num="11"></td><td><pre></pre></td></tr><tr><td data-num="12"></td><td><pre><span class="token comment"># 获取负离子模式下的 MV 数量</span></pre></td></tr><tr><td data-num="13"></td><td><pre>get_mv_number<span class="token punctuation">(</span>object_neg<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token comment">#> [1] 146409</span></pre></td></tr><tr><td data-num="15"></td><td><pre></pre></td></tr><tr><td data-num="16"></td><td><pre><span class="token comment"># 填充正离子模式缺失值</span></pre></td></tr><tr><td data-num="17"></td><td><pre>object_neg <span class="token operator">&lt;-</span> impute_mv<span class="token punctuation">(</span>object <span class="token operator">=</span> object_neg<span class="token punctuation">,</span> method <span class="token operator">=</span> <span class="token string">"knn"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="18"></td><td><pre></pre></td></tr><tr><td data-num="19"></td><td><pre><span class="token comment"># 获取正离子模式下填充后的 MV 数量</span></pre></td></tr><tr><td data-num="20"></td><td><pre>get_mv_number<span class="token punctuation">(</span>object_neg<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="21"></td><td><pre><span class="token comment">#> [1] 0</span></pre></td></tr></table></figure><h2 id="数据标准化与整合data-normalization-and-integration"><a class="anchor" href="#数据标准化与整合data-normalization-and-integration">#</a> 数据标准化与整合（Data normalization and integration）</h2><p>数据标准化处理， 利用内标（internal standard, IS）进行归一化<font color="#FF0000">待确认是否通过 IS 实现</font>。</p><ul><li><p>正离子模式</p><p>标准化方法包括：&quot;svr&quot;, &quot;total&quot;, &quot;median&quot;, &quot;mean&quot;, &quot;pqn&quot;, &quot;loess&quot;；整合方法包括：&quot;qc_mean&quot;, &quot;qc_median&quot;, &quot;subject_mean&quot;, &quot;subject_median&quot;。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>object_pos <span class="token operator">&lt;-</span> normalize_data<span class="token punctuation">(</span>object_pos<span class="token punctuation">,</span> method <span class="token operator">=</span> <span class="token string">"median"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre>object_pos2 <span class="token operator">&lt;-</span> integrate_data<span class="token punctuation">(</span>object_pos<span class="token punctuation">,</span> method <span class="token operator">=</span> <span class="token string">"subject_median"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># 按批次分组绘制 PCA 图</span></pre></td></tr><tr><td data-num="6"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/POS/PC_batch_intergrated.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre>object_pos2 <span class="token percent-operator operator">%>%</span> `<span class="token operator">+</span>`<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> log<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> massqc<span class="token operator">::</span>massqc_pca<span class="token punctuation">(</span>color_by <span class="token operator">=</span> <span class="token string">"batch"</span><span class="token punctuation">,</span> line <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_10.svg" alt="标准化后正离子PCA"></p><ul><li><p>负离子模式</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>object_neg <span class="token operator">&lt;-</span> normalize_data<span class="token punctuation">(</span>object_neg<span class="token punctuation">,</span> method <span class="token operator">=</span> <span class="token string">"median"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre>object_neg2 <span class="token operator">&lt;-</span> integrate_data<span class="token punctuation">(</span>object_neg<span class="token punctuation">,</span> method <span class="token operator">=</span> <span class="token string">"subject_median"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token comment"># 按批次分组绘制 PCA 图</span></pre></td></tr><tr><td data-num="6"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"data_cleaning/NEG/PC_batch_intergrated.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre>object_neg2 <span class="token percent-operator operator">%>%</span> `<span class="token operator">+</span>`<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> log<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> massqc<span class="token operator">::</span>massqc_pca<span class="token punctuation">(</span>color_by <span class="token operator">=</span> <span class="token string">"batch"</span><span class="token punctuation">,</span> line <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_11.svg" alt="标准化后负离子PCA"></p><p><strong>保存数据</strong></p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>save<span class="token punctuation">(</span>object_pos2<span class="token punctuation">,</span> file <span class="token operator">=</span> <span class="token string">"data_cleaning/POS/object_pos2"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>save<span class="token punctuation">(</span>object_neg2<span class="token punctuation">,</span> file <span class="token operator">=</span> <span class="token string">"data_cleaning/NEG/object_neg2"</span><span class="token punctuation">)</span></pre></td></tr></table></figure><h2 id="代谢物注释"><a class="anchor" href="#代谢物注释">#</a> 代谢物注释</h2><h3 id="加载数据"><a class="anchor" href="#加载数据">#</a> 加载数据</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"data_cleaning/POS/object_pos2"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"data_cleaning/NEG/object_neg2"</span><span class="token punctuation">)</span></pre></td></tr></table></figure><h3 id="将ms2数据添加到mass_dataset"><a class="anchor" href="#将ms2数据添加到mass_dataset">#</a> 将 MS2 数据添加到 mass_dataset</h3><p><strong>如果没有 MS2 数据，此步不执行应该也可以！</strong><br><font color="#FF0000">？？只有 QC 样的 MS2 数据，MS2 数据是怎么来的？</font></p><ul><li><p>正离子模式</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>object_pos2 <span class="token operator">&lt;-</span> mutate_ms2<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="2"></td><td><pre>  object <span class="token operator">=</span> object_pos2<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="3"></td><td><pre>  column <span class="token operator">=</span> <span class="token string">"rp"</span><span class="token punctuation">,</span> <span class="token comment"># rp or hilic，对应 RPLC（反相色谱）和 HILIC（亲水相互作用色谱）</span></pre></td></tr><tr><td data-num="4"></td><td><pre>  polarity <span class="token operator">=</span> <span class="token string">"positive"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="5"></td><td><pre>  ms1.ms2.match.mz.tol <span class="token operator">=</span> <span class="token number">15</span><span class="token punctuation">,</span><span class="token comment"># ppm</span></pre></td></tr><tr><td data-num="6"></td><td><pre>  ms1.ms2.match.rt.tol <span class="token operator">=</span> <span class="token number">30</span><span class="token punctuation">,</span><span class="token comment"># seconds</span></pre></td></tr><tr><td data-num="7"></td><td><pre>  path <span class="token operator">=</span> <span class="token string">"mgf_ms2_data/mgf_ms2_data/POS"</span></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token comment">#1043 out of 5101 variable have MS2 spectra.</span></pre></td></tr><tr><td data-num="10"></td><td><pre><span class="token comment">#Selecting the most intense MS2 spectrum for each peak...</span></pre></td></tr><tr><td data-num="11"></td><td><pre></pre></td></tr><tr><td data-num="12"></td><td><pre><span class="token comment"># summary</span></pre></td></tr><tr><td data-num="13"></td><td><pre>extract_ms2_data<span class="token punctuation">(</span>object_pos2<span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>负离子模式</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>object_neg2 <span class="token operator">&lt;-</span> mutate_ms2<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="2"></td><td><pre>  object <span class="token operator">=</span> object_neg2<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="3"></td><td><pre>  column <span class="token operator">=</span> <span class="token string">"rp"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="4"></td><td><pre>  polarity <span class="token operator">=</span> <span class="token string">"negative"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="5"></td><td><pre>  ms1.ms2.match.mz.tol <span class="token operator">=</span> <span class="token number">15</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="6"></td><td><pre>  ms1.ms2.match.rt.tol <span class="token operator">=</span> <span class="token number">30</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="7"></td><td><pre>  path <span class="token operator">=</span> <span class="token string">"mgf_ms2_data/mgf_ms2_data/NEG"</span></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token comment">#1092 out of 4104 variable have MS2 spectra.</span></pre></td></tr><tr><td data-num="10"></td><td><pre><span class="token comment">#Selecting the most intense MS2 spectrum for each peak...</span></pre></td></tr><tr><td data-num="11"></td><td><pre></pre></td></tr><tr><td data-num="12"></td><td><pre><span class="token comment"># summary</span></pre></td></tr><tr><td data-num="13"></td><td><pre>extract_ms2_data<span class="token punctuation">(</span>object_neg2<span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><h3 id="代谢物注释-2"><a class="anchor" href="#代谢物注释-2">#</a> 代谢物注释</h3><p><font color="#FF0000">需要考虑数据库是 RPLC 还是 HILIC。</font></p><ul><li><p>正离子模式</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># Annotate features using snyder_database_rplc0.0.3</span></pre></td></tr><tr><td data-num="2"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"metabolite_annotation/snyder_database_rplc0.0.3.rda"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token comment">## 查看数据库信息</span></pre></td></tr><tr><td data-num="5"></td><td><pre>snyder_database_rplc0.<span class="token number">0.3</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment">## 注释</span></pre></td></tr><tr><td data-num="8"></td><td><pre>object_pos2 <span class="token operator">&lt;-</span> annotate_metabolites_mass_dataset<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="9"></td><td><pre>    object <span class="token operator">=</span> object_pos2<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="10"></td><td><pre>    ms1.match.ppm <span class="token operator">=</span> <span class="token number">15</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="11"></td><td><pre>    rt.match.tol <span class="token operator">=</span> <span class="token number">30</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="12"></td><td><pre>    polarity <span class="token operator">=</span> <span class="token string">"positive"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="13"></td><td><pre>    database <span class="token operator">=</span> snyder_database_rplc0.<span class="token number">0.3</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="14"></td><td><pre>    threads <span class="token operator">=</span><span class="token number">30</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="15"></td><td><pre></pre></td></tr><tr><td data-num="16"></td><td><pre><span class="token comment"># Annotate features using orbitrap_database0.0.3</span></pre></td></tr><tr><td data-num="17"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"metabolite_annotation/orbitrap_database0.0.3.rda"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="18"></td><td><pre></pre></td></tr><tr><td data-num="19"></td><td><pre><span class="token comment">## 查看数据库信息</span></pre></td></tr><tr><td data-num="20"></td><td><pre>orbitrap_database0.<span class="token number">0.3</span></pre></td></tr><tr><td data-num="21"></td><td><pre></pre></td></tr><tr><td data-num="22"></td><td><pre><span class="token comment">## 注释</span></pre></td></tr><tr><td data-num="23"></td><td><pre>object_pos2 <span class="token operator">&lt;-</span> annotate_metabolites_mass_dataset<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="24"></td><td><pre>    object <span class="token operator">=</span> object_pos2<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="25"></td><td><pre>    ms1.match.ppm <span class="token operator">=</span> <span class="token number">15</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="26"></td><td><pre>    polarity <span class="token operator">=</span> <span class="token string">"positive"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="27"></td><td><pre>    database <span class="token operator">=</span> orbitrap_database0.<span class="token number">0.3</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="28"></td><td><pre>    threads <span class="token operator">=</span><span class="token number">30</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="29"></td><td><pre></pre></td></tr><tr><td data-num="30"></td><td><pre><span class="token comment"># Annotate features using mona_database0.0.3</span></pre></td></tr><tr><td data-num="31"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"metabolite_annotation/mona_database0.0.3.rda"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="32"></td><td><pre></pre></td></tr><tr><td data-num="33"></td><td><pre><span class="token comment">## 查看数据库信息</span></pre></td></tr><tr><td data-num="34"></td><td><pre>mona_database0.<span class="token number">0.3</span></pre></td></tr><tr><td data-num="35"></td><td><pre></pre></td></tr><tr><td data-num="36"></td><td><pre><span class="token comment">## 注释</span></pre></td></tr><tr><td data-num="37"></td><td><pre>object_pos2 <span class="token operator">&lt;-</span> annotate_metabolites_mass_dataset<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="38"></td><td><pre>    object <span class="token operator">=</span> object_pos2<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="39"></td><td><pre>    ms1.match.ppm <span class="token operator">=</span> <span class="token number">15</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="40"></td><td><pre>    polarity <span class="token operator">=</span> <span class="token string">"positive"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="41"></td><td><pre>    database <span class="token operator">=</span> mona_database0.<span class="token number">0.3</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="42"></td><td><pre>    threads <span class="token operator">=</span><span class="token number">30</span><span class="token punctuation">)</span></pre></td></tr></table></figure><p><strong>annotate_metabolites_mass_dataset 参数解析</strong>：</p><ul><li><strong>ms1.match.ppm</strong>：Precursor match ppm tolerance [25].</li><li><strong>ms2.match.ppm</strong>：Fragment ion match ppm tolerance [30].</li><li><strong>mz.ppm.thr</strong>：Accurate mass tolerance for m/z error calculation [400].</li><li><strong>ms2.match.tol</strong>：MS2 match (MS2 similarity) tolerance [0.5].</li><li><strong>fraction.weight</strong>：The weight for matched fragments [0.3].</li><li><strong>dp.forward.weight</strong>：Forward dot product weight [0.6].</li><li><strong>dp.reverse.weight</strong>：Reverse dot product weight [0.1].</li><li><strong>remove_fragment_intensity_cutoff</strong>：remove_fragment_intensity_cutoff [0].</li><li><strong>rt.match.tol</strong>：RT match tolerance [30].</li><li><strong>polarity</strong>：The polarity of data, &quot;positive&quot;or &quot;negative&quot;.</li><li><strong>ce</strong>：Collision energy. Please confirm the CE values in your database. [all].</li><li><strong>column</strong>：&quot;hilic&quot; (HILIC column) or &quot;rp&quot; (reverse phase).</li><li><strong>ms1.match.weight</strong>：The weight of MS1 match for total score calculation [0.25].</li><li><strong>rt.match.weight</strong>：The weight of RT match for total score calculation [0.25].</li><li><strong>ms2.match.weight</strong>：The weight of MS2 match for total score calculation [0.5]</li><li><strong>total.score.tol</strong>：Total score tolerance. The total score are referring to MS-DIAL [0.5]</li><li><strong>candidate.num</strong>：The number of candidate [3]</li></ul></li><li><p>负离子模式</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># Annotate features using snyder_database_rplc0.0.3</span></pre></td></tr><tr><td data-num="2"></td><td><pre>object_neg2 <span class="token operator">&lt;-</span> annotate_metabolites_mass_dataset<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="3"></td><td><pre>    object <span class="token operator">=</span> object_neg2<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="4"></td><td><pre>    ms1.match.ppm <span class="token operator">=</span> <span class="token number">15</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="5"></td><td><pre>    rt.match.tol <span class="token operator">=</span> <span class="token number">30</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="6"></td><td><pre>    polarity <span class="token operator">=</span> <span class="token string">"negative"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="7"></td><td><pre>    database <span class="token operator">=</span> snyder_database_rplc0.<span class="token number">0.3</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token comment"># Annotate features using orbitrap_database0.0.3</span></pre></td></tr><tr><td data-num="10"></td><td><pre>object_neg2 <span class="token operator">&lt;-</span> annotate_metabolites_mass_dataset<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="11"></td><td><pre>    object <span class="token operator">=</span> object_neg2<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="12"></td><td><pre>    ms1.match.ppm <span class="token operator">=</span> <span class="token number">15</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="13"></td><td><pre>    polarity <span class="token operator">=</span> <span class="token string">"negative"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="14"></td><td><pre>    database <span class="token operator">=</span> orbitrap_database0.<span class="token number">0.3</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="15"></td><td><pre></pre></td></tr><tr><td data-num="16"></td><td><pre><span class="token comment"># Annotate features using mona_database0.0.3</span></pre></td></tr><tr><td data-num="17"></td><td><pre>object_neg2 <span class="token operator">&lt;-</span> annotate_metabolites_mass_dataset<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="18"></td><td><pre>    object <span class="token operator">=</span> object_neg2<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="19"></td><td><pre>    ms1.match.ppm <span class="token operator">=</span> <span class="token number">15</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="20"></td><td><pre>    polarity <span class="token operator">=</span> <span class="token string">"negative"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="21"></td><td><pre>    database <span class="token operator">=</span> mona_database0.<span class="token number">0.3</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><h3 id="查看注释结果"><a class="anchor" href="#查看注释结果">#</a> 查看注释结果</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>head<span class="token punctuation">(</span>extract_annotation_table<span class="token punctuation">(</span>object <span class="token operator">=</span> object_pos2<span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre>variable_info_pos <span class="token operator">&lt;-</span> extract_variable_info<span class="token punctuation">(</span>object <span class="token operator">=</span> object_pos2<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre></pre></td></tr><tr><td data-num="5"></td><td><pre>head<span class="token punctuation">(</span>variable_info_pos<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre>table<span class="token punctuation">(</span>variable_info_pos<span class="token operator">$</span>Level<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre></pre></td></tr><tr><td data-num="9"></td><td><pre>table<span class="token punctuation">(</span>variable_info_pos<span class="token operator">$</span>Database<span class="token punctuation">)</span></pre></td></tr></table></figure><h3 id="保存数据"><a class="anchor" href="#保存数据">#</a> 保存数据</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>save<span class="token punctuation">(</span>object_pos2<span class="token punctuation">,</span> file <span class="token operator">=</span> <span class="token string">"metabolite_annotation/object_pos2"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>save<span class="token punctuation">(</span>object_neg2<span class="token punctuation">,</span> file <span class="token operator">=</span> <span class="token string">"metabolite_annotation/object_neg2"</span><span class="token punctuation">)</span></pre></td></tr></table></figure><h2 id="统计分析"><a class="anchor" href="#统计分析">#</a> 统计分析</h2><h3 id="加载数据-2"><a class="anchor" href="#加载数据-2">#</a> 加载数据</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>library<span class="token punctuation">(</span>tidymass<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>library<span class="token punctuation">(</span>tidyverse<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"metabolite_annotation/object_pos2"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"metabolite_annotation/object_neg2"</span><span class="token punctuation">)</span></pre></td></tr></table></figure><h3 id="移除未被注释的features"><a class="anchor" href="#移除未被注释的features">#</a> 移除未被注释的 features</h3><ul><li><p>正离子模式</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>object_pos2 <span class="token operator">&lt;-</span> object_pos2 <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"annotation_table"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span><span class="token operator">!</span>is.na<span class="token punctuation">(</span>Level<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>Level <span class="token operator">==</span> <span class="token number">1</span> <span class="token operator">|</span> Level <span class="token operator">==</span> <span class="token number">2</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>  </pre></td></tr><tr><td data-num="3"></td><td><pre>  object_pos2</pre></td></tr></table></figure></li><li><p>负离子模式</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>object_neg2 <span class="token operator">&lt;-</span> object_neg2 <span class="token percent-operator operator">%>%</span> activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"annotation_table"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span><span class="token operator">!</span>is.na<span class="token punctuation">(</span>Level<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>Level <span class="token operator">==</span> <span class="token number">1</span> <span class="token operator">|</span> Level <span class="token operator">==</span> <span class="token number">2</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre>object_neg2</pre></td></tr></table></figure></li></ul><h3 id="合并pos和neg数据"><a class="anchor" href="#合并pos和neg数据">#</a> 合并 POS 和 NEG 数据</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># inner merge for samples and full merge for variables</span></pre></td></tr><tr><td data-num="2"></td><td><pre>object <span class="token operator">&lt;-</span> </pre></td></tr><tr><td data-num="3"></td><td><pre>merge_mass_dataset<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="4"></td><td><pre>    x <span class="token operator">=</span> object_pos2<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="5"></td><td><pre>    y <span class="token operator">=</span> object_neg2<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="6"></td><td><pre>    sample_direction <span class="token operator">=</span> <span class="token string">"inner"</span><span class="token punctuation">,</span><span class="token comment"># left, right, inner or full，此处用 inner 较合理</span></pre></td></tr><tr><td data-num="7"></td><td><pre>    variable_direction <span class="token operator">=</span> <span class="token string">"full"</span><span class="token punctuation">,</span><span class="token comment"># left, right, inner or full，此处用 full 合理</span></pre></td></tr><tr><td data-num="8"></td><td><pre>    sample_by <span class="token operator">=</span> <span class="token string">"sample_id"</span><span class="token punctuation">,</span> <span class="token comment"># merge samples by what columns from sample_info</span></pre></td></tr><tr><td data-num="9"></td><td><pre>    variable_by <span class="token operator">=</span> c<span class="token punctuation">(</span><span class="token string">"variable_id"</span><span class="token punctuation">,</span> <span class="token string">"mz"</span><span class="token punctuation">,</span> <span class="token string">"rt"</span><span class="token punctuation">)</span><span class="token comment"># merge variables by what columns from variable_info</span></pre></td></tr><tr><td data-num="10"></td><td><pre><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="11"></td><td><pre></pre></td></tr><tr><td data-num="12"></td><td><pre>object</pre></td></tr></table></figure><p><strong>名词解释：</strong></p><ul><li><strong>左连接 (Left join)</strong>：将左表中的所有记录都保留下来，而右表中与左表中记录没有匹配的部分则丢弃。</li><li><strong>右连接 (Right join)</strong>：将右表中的所有记录都保留下来，而左表中与右表中记录没有匹配的部分则丢弃。</li><li><strong>内连接 (Inner join)</strong>：只有两个表中都存在的记录才保留下来，否则丢弃。</li><li><strong>全连接 (Full join)</strong>：将左表和右表中的所有记录都保留下来，如果某个表中的记录没有匹配到另一个表中的记录，则用 NULL 填充。</li></ul><h3 id="trace-processing-information-of-object"><a class="anchor" href="#trace-processing-information-of-object">#</a> Trace processing information of object</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>dir.create<span class="token punctuation">(</span>path <span class="token operator">=</span> <span class="token string">"statistical_analysis"</span><span class="token punctuation">,</span> showWarnings <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre>report_parameters<span class="token punctuation">(</span>object <span class="token operator">=</span> object<span class="token punctuation">,</span> path <span class="token operator">=</span> <span class="token string">"statistical_analysis/"</span><span class="token punctuation">)</span></pre></td></tr></table></figure><h3 id="基于level和score移除冗余注释代谢物"><a class="anchor" href="#基于level和score移除冗余注释代谢物">#</a> 基于 level 和 score 移除冗余注释代谢物</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>object <span class="token operator">&lt;-</span> object <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="2"></td><td><pre>  activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"annotation_table"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="3"></td><td><pre>  group_by<span class="token punctuation">(</span>Compound.name<span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="4"></td><td><pre>  filter<span class="token punctuation">(</span>Level <span class="token operator">==</span> min<span class="token punctuation">(</span>Level<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="5"></td><td><pre>  filter<span class="token punctuation">(</span>SS <span class="token operator">==</span> max<span class="token punctuation">(</span>SS<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="6"></td><td><pre>  slice_head<span class="token punctuation">(</span>n <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre>object <span class="token operator">&lt;-</span> object <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="9"></td><td><pre>  activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"annotation_table"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="10"></td><td><pre>  group_by<span class="token punctuation">(</span>variable_id<span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="11"></td><td><pre>  filter<span class="token punctuation">(</span>Level <span class="token operator">==</span> min<span class="token punctuation">(</span>Level<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="12"></td><td><pre>  filter<span class="token punctuation">(</span>SS <span class="token operator">==</span> max<span class="token punctuation">(</span>SS<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="13"></td><td><pre>  slice_head<span class="token punctuation">(</span>n <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span></pre></td></tr></table></figure><p><font color="#FF0000">为何要选最小的 level？SS 是什么 score？</font></p><h3 id="样本聚类"><a class="anchor" href="#样本聚类">#</a> 样本聚类</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"statistical_analysis/object_final"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token comment"># 排除 QC 样本</span></pre></td></tr><tr><td data-num="4"></td><td><pre>temp_object <span class="token operator">&lt;-</span> object_final <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="5"></td><td><pre>  activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="6"></td><td><pre>  filter<span class="token punctuation">(</span>group <span class="token operator">!=</span> <span class="token string">"QC"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="7"></td><td><pre>  `<span class="token operator">+</span>`<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="8"></td><td><pre>  log<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="9"></td><td><pre>  scale<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="10"></td><td><pre></pre></td></tr><tr><td data-num="11"></td><td><pre>library<span class="token punctuation">(</span>ComplexHeatmap<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre>h1 <span class="token operator">&lt;-</span> HeatmapAnnotation<span class="token punctuation">(</span>class <span class="token operator">=</span> extract_sample_info<span class="token punctuation">(</span>temp_object<span class="token punctuation">)</span><span class="token operator">$</span>group<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="13"></td><td><pre></pre></td></tr><tr><td data-num="14"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"statistical_analysis/Samples_heatmap.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="15"></td><td><pre>massstat<span class="token operator">::</span>Heatmap<span class="token punctuation">(</span>matrix <span class="token operator">=</span> temp_object<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="16"></td><td><pre>                  name <span class="token operator">=</span> <span class="token string">"z-score"</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="17"></td><td><pre>                  row_names_gp <span class="token operator">=</span> gpar<span class="token punctuation">(</span>cex <span class="token operator">=</span> <span class="token number">0.2</span><span class="token punctuation">)</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="18"></td><td><pre>                  column_names_gp <span class="token operator">=</span> gpar<span class="token punctuation">(</span>cex <span class="token operator">=</span> <span class="token number">0.2</span><span class="token punctuation">)</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="19"></td><td><pre>                  top_annotation <span class="token operator">=</span> h1<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="20"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr></table></figure><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_16.png" alt="样本聚类热图"></p><h3 id="差异表达代谢物"><a class="anchor" href="#差异表达代谢物">#</a> 差异表达代谢物</h3><p><font color="#FF0000">如果有多组数据，需要适当增加相应下述代码。“mutate_fc” 的逻辑是每运行一次，则在 object 中增加一列 “fc”，当有多个实验组时，可以将先前生成的 fc 重命名，因此，object 中可以包含多个组间比较的 fc 结果。</font></p><ul><li><p>计算变化倍数</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment"># 获取对照组样本名列表</span></pre></td></tr><tr><td data-num="2"></td><td><pre>control_sample_id <span class="token operator">=</span> object <span class="token percent-operator operator">%>%</span></pre></td></tr><tr><td data-num="3"></td><td><pre>activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span></pre></td></tr><tr><td data-num="4"></td><td><pre>filter<span class="token punctuation">(</span>group <span class="token operator">==</span> <span class="token string">"Control"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span></pre></td></tr><tr><td data-num="5"></td><td><pre>pull<span class="token punctuation">(</span>sample_id<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># 获取实验组样本名列表</span></pre></td></tr><tr><td data-num="8"></td><td><pre>case_sample_id <span class="token operator">=</span> object <span class="token percent-operator operator">%>%</span></pre></td></tr><tr><td data-num="9"></td><td><pre>activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span></pre></td></tr><tr><td data-num="10"></td><td><pre>filter<span class="token punctuation">(</span>group <span class="token operator">==</span> <span class="token string">"Case"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span></pre></td></tr><tr><td data-num="11"></td><td><pre>pull<span class="token punctuation">(</span>sample_id<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre></pre></td></tr><tr><td data-num="13"></td><td><pre><span class="token comment">#! 如果有多个实验组，参照以上格式在此列出，假设有实验组 Case2</span></pre></td></tr><tr><td data-num="14"></td><td><pre>case2_sample_id <span class="token operator">=</span> object <span class="token percent-operator operator">%>%</span></pre></td></tr><tr><td data-num="15"></td><td><pre>activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span></pre></td></tr><tr><td data-num="16"></td><td><pre>filter<span class="token punctuation">(</span>group <span class="token operator">==</span> <span class="token string">"Case2"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span></pre></td></tr><tr><td data-num="17"></td><td><pre>pull<span class="token punctuation">(</span>sample_id<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="18"></td><td><pre></pre></td></tr><tr><td data-num="19"></td><td><pre><span class="token comment"># Calculate fold change，每次只能计算两个分组，如果有多个实验组，则依次将其与对照组比较</span></pre></td></tr><tr><td data-num="20"></td><td><pre>object <span class="token operator">&lt;-</span> mutate_fc<span class="token punctuation">(</span>object <span class="token operator">=</span> object<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="21"></td><td><pre>          control_sample_id <span class="token operator">=</span> control_sample_id<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="22"></td><td><pre>          case_sample_id <span class="token operator">=</span> case_sample_id<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="23"></td><td><pre>          mean_median <span class="token operator">=</span> <span class="token string">"mean"</span><span class="token punctuation">)</span><span class="token comment">#可选 "mean", "median"</span></pre></td></tr><tr><td data-num="24"></td><td><pre><span class="token comment">#> 110 control samples.</span></pre></td></tr><tr><td data-num="25"></td><td><pre><span class="token comment">#> 110 case samples.</span></pre></td></tr><tr><td data-num="26"></td><td><pre></pre></td></tr><tr><td data-num="27"></td><td><pre><span class="token comment">#! 如果有多个实验组，则需要在此更改 fc 列的默认名，假设将默认的 “fc” 改为 “fc_case1_vs_control”</span></pre></td></tr><tr><td data-num="28"></td><td><pre>object <span class="token operator">&lt;-</span>  object <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="29"></td><td><pre>activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"variable_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="30"></td><td><pre>dplyr<span class="token operator">::</span>rename<span class="token punctuation">(</span>fc_case1_vs_control <span class="token operator">=</span> fc<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="31"></td><td><pre></pre></td></tr><tr><td data-num="32"></td><td><pre><span class="token comment">#! Calculate fold change，每次只能计算两个分组，如果有多个实验组，则依次将其与对照组比较，此处计算 Case2 与 Control</span></pre></td></tr><tr><td data-num="33"></td><td><pre>object <span class="token operator">&lt;-</span> mutate_fc<span class="token punctuation">(</span>object <span class="token operator">=</span> object<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="34"></td><td><pre>          control_sample_id <span class="token operator">=</span> control_sample_id<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="35"></td><td><pre>          case_sample_id <span class="token operator">=</span> case2_sample_id<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="36"></td><td><pre>          mean_median <span class="token operator">=</span> <span class="token string">"mean"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="37"></td><td><pre><span class="token comment">#> 110 control samples.</span></pre></td></tr><tr><td data-num="38"></td><td><pre><span class="token comment">#> 110 case samples.</span></pre></td></tr><tr><td data-num="39"></td><td><pre></pre></td></tr><tr><td data-num="40"></td><td><pre><span class="token comment">#! 如果有多个实验组，则需要在此更改 fc 列的默认名，假设将默认的 “fc” 改为 “fc_case2_vs_control”</span></pre></td></tr><tr><td data-num="41"></td><td><pre>object <span class="token operator">&lt;-</span>  object <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="42"></td><td><pre>activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"variable_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="43"></td><td><pre>dplyr<span class="token operator">::</span>rename<span class="token punctuation">(</span>fc_case2_vs_control <span class="token operator">=</span> fc<span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>计算 p 值<br><font color="#FF0000">同理，当有多个实验组时，也可以分别计算 p 值，并将默认的列名 “p_value” 和 “p_value_adjust” 重命名，以在 object 中容纳多组相互比较的 p 值。</font></p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>object <span class="token operator">&lt;-</span> mutate_p_value<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="2"></td><td><pre>  object <span class="token operator">=</span> object<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="3"></td><td><pre>  control_sample_id <span class="token operator">=</span> control_sample_id<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="4"></td><td><pre>  case_sample_id <span class="token operator">=</span> case_sample_id<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="5"></td><td><pre>  method <span class="token operator">=</span> <span class="token string">"t.test"</span><span class="token punctuation">,</span><span class="token comment"># "t.test", "wilcox.test"</span></pre></td></tr><tr><td data-num="6"></td><td><pre>  p_adjust_methods <span class="token operator">=</span> <span class="token string">"BH"</span><span class="token comment"># "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none"</span></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment">#> 110 control samples.</span></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token comment">#> 110 case samples.</span></pre></td></tr><tr><td data-num="10"></td><td><pre></pre></td></tr><tr><td data-num="11"></td><td><pre><span class="token comment">#! 如果涉及多组间的比较，则需重命名默认表头</span></pre></td></tr><tr><td data-num="12"></td><td><pre>object <span class="token operator">&lt;-</span>  object <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="13"></td><td><pre>activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"variable_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="14"></td><td><pre>dplyr<span class="token operator">::</span>rename<span class="token punctuation">(</span>p_value_case1_vs_control <span class="token operator">=</span> p_value<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="15"></td><td><pre>       p_value_adjust_case1_vs_control <span class="token operator">=</span> p_value_adjust<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="16"></td><td><pre>  </pre></td></tr><tr><td data-num="17"></td><td><pre><span class="token comment">#! 假设存在 Case2 组</span></pre></td></tr><tr><td data-num="18"></td><td><pre>object <span class="token operator">&lt;-</span> mutate_p_value<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="19"></td><td><pre>  object <span class="token operator">=</span> object<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="20"></td><td><pre>  control_sample_id <span class="token operator">=</span> control_sample_id<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="21"></td><td><pre>  case_sample_id <span class="token operator">=</span> case2_sample_id<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="22"></td><td><pre>  method <span class="token operator">=</span> <span class="token string">"t.test"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="23"></td><td><pre>  p_adjust_methods <span class="token operator">=</span> <span class="token string">"BH"</span></pre></td></tr><tr><td data-num="24"></td><td><pre><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="25"></td><td><pre><span class="token comment">#> 110 control samples.</span></pre></td></tr><tr><td data-num="26"></td><td><pre><span class="token comment">#> 110 case samples.</span></pre></td></tr><tr><td data-num="27"></td><td><pre></pre></td></tr><tr><td data-num="28"></td><td><pre><span class="token comment">#! 如果涉及多组间的比较，则需重命名默认表头</span></pre></td></tr><tr><td data-num="29"></td><td><pre>object <span class="token operator">&lt;-</span>  object <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="30"></td><td><pre>activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"variable_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="31"></td><td><pre>dplyr<span class="token operator">::</span>rename<span class="token punctuation">(</span>p_value_case2_vs_control <span class="token operator">=</span> p_value<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="32"></td><td><pre>       p_value_adjust_case2_vs_control <span class="token operator">=</span> p_value_adjust<span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>绘制火山图</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"statistical_analysis/Volcano.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre>p<span class="token operator">&lt;-</span> volcano_plot<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="4"></td><td><pre>    object <span class="token operator">=</span> object<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="5"></td><td><pre>    fc_column_name <span class="token operator">=</span> <span class="token string">"fc"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="6"></td><td><pre>    p_value_column_name <span class="token operator">=</span> <span class="token string">"p_value_adjust"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="7"></td><td><pre>    fc_up_cutoff <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="8"></td><td><pre>    fc_down_cutoff <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="9"></td><td><pre>    p_value_cutoff <span class="token operator">=</span> <span class="token number">0.05</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="10"></td><td><pre>    add_text <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="11"></td><td><pre>    text_from <span class="token operator">=</span> <span class="token string">"Compound.name"</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="12"></td><td><pre>    point_size_scale <span class="token operator">=</span> <span class="token string">"p_value_adjust"</span></pre></td></tr></table></figure></li></ul><p>)</p><p>p + scale_size_continuous(range = c(0.5, 5))</p><p>dev.off()</p><pre><code>

![火山图](https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_12.png)

&lt;font color=&quot;#FF0000&quot;&gt;假设存在Case2，绘制火山图。&lt;/font&gt;

```r
pdf(file=&quot;statistical_analysis/Volcano2.pdf&quot;)

p&lt;- volcano_plot(object = object,
    fc_column_name = &quot;fc_case2_vs_control&quot;,# 重命名后
    p_value_column_name = &quot;p_value_adjust_case2_vs_control&quot;,# 重命名后
    fc_up_cutoff = 1, 
    fc_down_cutoff = 1,
    p_value_cutoff = 0.05,
           add_text = TRUE,
           text_from = &quot;Compound.name&quot;, 
           point_size_scale = &quot;p_value_adjust_case2_vs_control&quot;) # 重命名后

p + scale_size_continuous(range = c(0.5, 5))

dev.off()
</code></pre><h3 id="保存结果"><a class="anchor" href="#保存结果">#</a> 保存结果</h3><ul><li><p>保存差异表达代谢物结果。如果有多个实验组，则将下述代码中的 “fc” 和 “p_value_adjust” 更改为重命名后的名称，并分别保存到不同的文件中。</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>differential_metabolites <span class="token operator">&lt;-</span> extract_variable_info<span class="token punctuation">(</span>object <span class="token operator">=</span> object<span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>fc <span class="token operator">></span> <span class="token number">2</span> <span class="token operator">|</span> fc <span class="token operator">&lt;</span> <span class="token number">0.5</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> filter<span class="token punctuation">(</span>p_value_adjust <span class="token operator">&lt;</span> <span class="token number">0.05</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre>readr<span class="token operator">::</span>write_csv<span class="token punctuation">(</span>differential_metabolites<span class="token punctuation">,</span> file <span class="token operator">=</span> <span class="token string">"statistical_analysis/differential_metabolites.csv"</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li><li><p>保存结果对象</p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>object_final <span class="token operator">&lt;-</span> object</pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre>save<span class="token punctuation">(</span>object_final<span class="token punctuation">,</span> file <span class="token operator">=</span> <span class="token string">"statistical_analysis/object_final"</span><span class="token punctuation">)</span></pre></td></tr></table></figure></li></ul><h3 id="绘制热图"><a class="anchor" href="#绘制热图">#</a> 绘制热图</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>temp_object <span class="token operator">&lt;-</span> object_final <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="2"></td><td><pre>  activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="3"></td><td><pre>  filter<span class="token punctuation">(</span>sample_id <span class="token percent-operator operator">%in%</span> c<span class="token punctuation">(</span>control_sample_id<span class="token punctuation">,</span> case_sample_id<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="4"></td><td><pre>  activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"variable_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="5"></td><td><pre>  filter<span class="token punctuation">(</span>variable_id <span class="token percent-operator operator">%in%</span> differential_metabolites<span class="token operator">$</span>variable_id<span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="6"></td><td><pre>  `<span class="token operator">+</span>`<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="7"></td><td><pre>  log<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="8"></td><td><pre>  scale<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre>library<span class="token punctuation">(</span>ComplexHeatmap<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="11"></td><td><pre>h1 <span class="token operator">&lt;-</span> HeatmapAnnotation<span class="token punctuation">(</span>class <span class="token operator">=</span> extract_sample_info<span class="token punctuation">(</span>temp_object<span class="token punctuation">)</span><span class="token operator">$</span>group<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre></pre></td></tr><tr><td data-num="13"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"statistical_analysis/diff_heatmap.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="14"></td><td><pre>massstat<span class="token operator">::</span>Heatmap<span class="token punctuation">(</span>matrix <span class="token operator">=</span> temp_object<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="15"></td><td><pre>                  name <span class="token operator">=</span> <span class="token string">"z-score"</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="16"></td><td><pre>                  row_names_gp <span class="token operator">=</span> gpar<span class="token punctuation">(</span>cex <span class="token operator">=</span> <span class="token number">0.4</span><span class="token punctuation">)</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="17"></td><td><pre>                  column_names_gp <span class="token operator">=</span> gpar<span class="token punctuation">(</span>cex <span class="token operator">=</span> <span class="token number">0.2</span><span class="token punctuation">)</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="18"></td><td><pre>                  top_annotation <span class="token operator">=</span> h1<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="19"></td><td><pre>                  row_labels <span class="token operator">=</span> extract_variable_info<span class="token punctuation">(</span>temp_object<span class="token punctuation">)</span><span class="token operator">$</span>Compound.name<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="20"></td><td><pre>                  border <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="21"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr></table></figure><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_17.png" alt="显著差异代谢物热图"></p><h2 id="代谢通路富集"><a class="anchor" href="#代谢通路富集">#</a> 代谢通路富集</h2><h3 id="导入数据"><a class="anchor" href="#导入数据">#</a> 导入数据</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>library<span class="token punctuation">(</span>tidymass<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre>library<span class="token punctuation">(</span>tidyverse<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre>load<span class="token punctuation">(</span><span class="token string">"statistical_analysis/object_final"</span><span class="token punctuation">)</span></pre></td></tr></table></figure><h4 id="富集"><a class="anchor" href="#富集">#</a> 富集</h4><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>dir.create<span class="token punctuation">(</span>path <span class="token operator">=</span> <span class="token string">"pathway_enrichment"</span><span class="token punctuation">,</span> showWarnings <span class="token operator">=</span> <span class="token boolean">FALSE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre>diff_metabolites <span class="token operator">&lt;-</span> object_final <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="4"></td><td><pre>  activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"variable_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="5"></td><td><pre>  filter<span class="token punctuation">(</span>p_value_adjust <span class="token operator">&lt;</span> <span class="token number">0.05</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="6"></td><td><pre>  extract_variable_info<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre>head<span class="token punctuation">(</span>diff_metabolites<span class="token punctuation">)</span></pre></td></tr></table></figure><h3 id="加载kegg-human-pathway数据库"><a class="anchor" href="#加载kegg-human-pathway数据库">#</a> 加载 KEGG human pathway 数据库</h3><p><font color="#FF0000">可选数据库：kegg_hsa_pathway，keggMS1database，query_id_kegg，hmdb_pathway，hmdbMS1Database，query_id_hmdb。</font></p><p><strong>？？这些数据库的区别是什么？</strong></p><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>data<span class="token punctuation">(</span><span class="token string">"kegg_hsa_pathway"</span><span class="token punctuation">,</span> package <span class="token operator">=</span> <span class="token string">"metpath"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre>kegg_hsa_pathway</pre></td></tr><tr><td data-num="4"></td><td><pre></pre></td></tr><tr><td data-num="5"></td><td><pre>get_pathway_class<span class="token punctuation">(</span>kegg_hsa_pathway<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token comment"># 移除疾病相关通路！根据课题选择是否移除？</span></pre></td></tr><tr><td data-num="8"></td><td><pre>pathway_class <span class="token operator">=</span> metpath<span class="token operator">::</span>pathway_class<span class="token punctuation">(</span>kegg_hsa_pathway<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre>head<span class="token punctuation">(</span>pathway_class<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="10"></td><td><pre></pre></td></tr><tr><td data-num="11"></td><td><pre>remain_idx <span class="token operator">=</span> pathway_class <span class="token percent-operator operator">%>%</span> unlist<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> stringr<span class="token operator">::</span>str_detect<span class="token punctuation">(</span><span class="token string">"Disease"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> `<span class="token operator">!</span>`<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> which<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre></pre></td></tr><tr><td data-num="13"></td><td><pre>pathway_database <span class="token operator">=</span> kegg_hsa_pathway<span class="token punctuation">[</span>remain_idx<span class="token punctuation">]</span></pre></td></tr><tr><td data-num="14"></td><td><pre>pathway_database</pre></td></tr><tr><td data-num="15"></td><td><pre></pre></td></tr><tr><td data-num="16"></td><td><pre>kegg_id <span class="token operator">&lt;-</span>  diff_metabolites<span class="token operator">$</span>KEGG.ID </pre></td></tr><tr><td data-num="17"></td><td><pre>kegg_id <span class="token operator">&lt;-</span>  kegg_id<span class="token punctuation">[</span><span class="token operator">!</span>is.na<span class="token punctuation">(</span>kegg_id<span class="token punctuation">)</span><span class="token punctuation">]</span></pre></td></tr><tr><td data-num="18"></td><td><pre></pre></td></tr><tr><td data-num="19"></td><td><pre>result <span class="token operator">&lt;-</span> enrich_kegg<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="20"></td><td><pre>    query_id <span class="token operator">=</span> kegg_id<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="21"></td><td><pre>    query_type <span class="token operator">=</span> <span class="token string">"compound"</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="22"></td><td><pre>    id_type <span class="token operator">=</span> <span class="token string">"KEGG"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="23"></td><td><pre>    pathway_database <span class="token operator">=</span> pathway_database<span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="24"></td><td><pre>    p_cutoff <span class="token operator">=</span> <span class="token number">0.05</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="25"></td><td><pre>    p_adjust_method <span class="token operator">=</span> <span class="token string">"BH"</span><span class="token punctuation">,</span> </pre></td></tr><tr><td data-num="26"></td><td><pre>    threads <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="27"></td><td><pre></pre></td></tr><tr><td data-num="28"></td><td><pre>result</pre></td></tr><tr><td data-num="29"></td><td><pre></pre></td></tr><tr><td data-num="30"></td><td><pre>save<span class="token punctuation">(</span>result<span class="token punctuation">,</span> file <span class="token operator">=</span> <span class="token string">"pathway_enrichment/result"</span><span class="token punctuation">)</span></pre></td></tr></table></figure><h3 id="绘制结果"><a class="anchor" href="#绘制结果">#</a> 绘制结果</h3><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre><span class="token comment">#  bar plot</span></pre></td></tr><tr><td data-num="2"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"pathway_enrichment/barplot.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="3"></td><td><pre></pre></td></tr><tr><td data-num="4"></td><td><pre>enrich_bar_plot<span class="token punctuation">(</span>object <span class="token operator">=</span> result<span class="token punctuation">,</span> x_axis <span class="token operator">=</span> <span class="token string">"p_value"</span><span class="token punctuation">,</span> cutoff <span class="token operator">=</span> <span class="token number">0.05</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre></pre></td></tr><tr><td data-num="6"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token comment"># scatter plot</span></pre></td></tr><tr><td data-num="9"></td><td><pre>pdf<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"pathway_enrichment/scatter_plot.pdf"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="10"></td><td><pre></pre></td></tr><tr><td data-num="11"></td><td><pre>enrich_scatter_plot<span class="token punctuation">(</span>object <span class="token operator">=</span> result<span class="token punctuation">,</span> y_axis <span class="token operator">=</span> <span class="token string">"p_value"</span><span class="token punctuation">,</span> y_axis_cutoff <span class="token operator">=</span> <span class="token number">0.05</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre></pre></td></tr><tr><td data-num="13"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="14"></td><td><pre></pre></td></tr><tr><td data-num="15"></td><td><pre><span class="token comment"># network</span></pre></td></tr><tr><td data-num="16"></td><td><pre>tiff<span class="token punctuation">(</span>file<span class="token operator">=</span><span class="token string">"pathway_enrichment/network.tiff"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="17"></td><td><pre></pre></td></tr><tr><td data-num="18"></td><td><pre>enrich_network<span class="token punctuation">(</span>object <span class="token operator">=</span> result<span class="token punctuation">,</span> point_size <span class="token operator">=</span> <span class="token string">"p_value"</span><span class="token punctuation">,</span> p_cutoff <span class="token operator">=</span> <span class="token number">0.05</span><span class="token punctuation">,</span> only_significant_pathway <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="19"></td><td><pre></pre></td></tr><tr><td data-num="20"></td><td><pre>dev.off<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr></table></figure><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_13.png" alt="KEGG富集bar plot"></p><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_14.png" alt="KEGG富集scatter plot"></p><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_15.png" alt="KEGG富集network"></p><h2 id="correlation-network-analysis"><a class="anchor" href="#correlation-network-analysis">#</a> Correlation network analysis</h2><figure class="highlight r"><figcaption data-lang="r"></figcaption><table><tr><td data-num="1"></td><td><pre>temp_object <span class="token operator">&lt;-</span> object_final <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="2"></td><td><pre>  activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"sample_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="3"></td><td><pre>  filter<span class="token punctuation">(</span>sample_id <span class="token percent-operator operator">%in%</span> c<span class="token punctuation">(</span>control_sample_id<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="4"></td><td><pre>  activate_mass_dataset<span class="token punctuation">(</span>what <span class="token operator">=</span> <span class="token string">"variable_info"</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="5"></td><td><pre>  filter<span class="token punctuation">(</span>variable_id <span class="token percent-operator operator">%in%</span> diff_metabolites<span class="token operator">$</span>variable_id<span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="6"></td><td><pre>  `<span class="token operator">+</span>`<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="7"></td><td><pre>  log<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="8"></td><td><pre>  scale<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre>library<span class="token punctuation">(</span>ggraph<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="11"></td><td><pre>library<span class="token punctuation">(</span>tidygraph<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre>graph_data <span class="token operator">&lt;-</span> convert_mass_dataset2graph<span class="token punctuation">(</span></pre></td></tr><tr><td data-num="13"></td><td><pre>    object <span class="token operator">=</span> temp_object<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="14"></td><td><pre>    margin <span class="token operator">=</span> <span class="token string">"variable"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="15"></td><td><pre>    cor_method <span class="token operator">=</span> <span class="token string">"spearman"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="16"></td><td><pre>    p_adjust_cutoff <span class="token operator">=</span> <span class="token number">0.05</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="17"></td><td><pre>    p_value_cutoff <span class="token operator">=</span> <span class="token number">0.05</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="18"></td><td><pre>    pos_cor_cutoff <span class="token operator">=</span> <span class="token number">0.7</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="19"></td><td><pre>    neg_cor_cutoff <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">0.7</span></pre></td></tr><tr><td data-num="20"></td><td><pre>  <span class="token punctuation">)</span> <span class="token percent-operator operator">%>%</span> </pre></td></tr><tr><td data-num="21"></td><td><pre>  mutate<span class="token punctuation">(</span>Degree <span class="token operator">=</span> centrality_degree<span class="token punctuation">(</span>mode <span class="token operator">=</span> <span class="token string">'all'</span><span class="token punctuation">)</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="22"></td><td><pre></pre></td></tr><tr><td data-num="23"></td><td><pre>library<span class="token punctuation">(</span>extrafont<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="24"></td><td><pre>loadfonts<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="25"></td><td><pre>library<span class="token punctuation">(</span>showtext<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="26"></td><td><pre>showtext_auto<span class="token punctuation">(</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="27"></td><td><pre>plot <span class="token operator">&lt;-</span> </pre></td></tr><tr><td data-num="28"></td><td><pre>ggraph<span class="token punctuation">(</span>graph <span class="token operator">=</span> graph_data<span class="token punctuation">,</span> layout <span class="token operator">=</span> <span class="token string">"kk"</span><span class="token punctuation">)</span> <span class="token operator">+</span></pre></td></tr><tr><td data-num="29"></td><td><pre>  geom_edge_fan<span class="token punctuation">(</span>aes<span class="token punctuation">(</span>color <span class="token operator">=</span> correlation<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="30"></td><td><pre>                    <span class="token comment">#width = -log((p_adjust+0.1), 10)),</span></pre></td></tr><tr><td data-num="31"></td><td><pre>                show.legend <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">+</span></pre></td></tr><tr><td data-num="32"></td><td><pre>  geom_node_point<span class="token punctuation">(</span>aes<span class="token punctuation">(</span>size <span class="token operator">=</span> Degree<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">+</span></pre></td></tr><tr><td data-num="33"></td><td><pre>  shadowtext<span class="token operator">::</span>geom_shadowtext<span class="token punctuation">(</span>aes<span class="token punctuation">(</span>x <span class="token operator">=</span> x<span class="token punctuation">,</span> y <span class="token operator">=</span> y<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="34"></td><td><pre>                                  label <span class="token operator">=</span> Compound.name<span class="token punctuation">)</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="35"></td><td><pre>                              bg.colour <span class="token operator">=</span> <span class="token string">"white"</span><span class="token punctuation">,</span></pre></td></tr><tr><td data-num="36"></td><td><pre>                              colour <span class="token operator">=</span> <span class="token string">"black"</span><span class="token punctuation">)</span><span class="token operator">+</span></pre></td></tr><tr><td data-num="37"></td><td><pre>  theme_graph<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span></pre></td></tr><tr><td data-num="38"></td><td><pre>  scale_edge_color_gradient2<span class="token punctuation">(</span>low <span class="token operator">=</span> <span class="token string">"darkblue"</span><span class="token punctuation">,</span> mid <span class="token operator">=</span> <span class="token string">"white"</span><span class="token punctuation">,</span> high <span class="token operator">=</span> <span class="token string">"red"</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="39"></td><td><pre></pre></td></tr><tr><td data-num="40"></td><td><pre>ggsave<span class="token punctuation">(</span>plot<span class="token punctuation">,</span> filename <span class="token operator">=</span> <span class="token string">"pathway_enrichment/cor_network.pdf"</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">12</span><span class="token punctuation">,</span> height <span class="token operator">=</span> <span class="token number">7</span><span class="token punctuation">)</span></pre></td></tr></table></figure><p><img data-src="https://fastly.jsdelivr.net/gh/liaochenlanruo/cdn@master/images/post/0_18.png" alt="代谢物Correlation network"></p><h1 id="术语"><a class="anchor" href="#术语">#</a> 术语</h1><ul><li><strong>HILIC</strong>（亲水相互作用色谱）&amp; <strong>RPLC</strong>（反相色谱）：RPLC 色谱柱主要使用非极性固定相（C18、C8 等），而 HILIC 色谱柱则使用极性固定相（二氧化硅、酰胺等）。两种技术采用的流动相通常由乙腈和水组成，这使得两种液相色谱模式之间可以实现轻松切换。HILIC 和 RPLC 流动相的主要区别在于溶剂洗脱强度。对于 RPLC，乙腈是强洗脱溶剂。但对于 HILIC，水是强洗脱溶剂。对于 RPLC，得到的色谱图通常是极性分析物到非极性分析物，而 HILIC 则相反。这种相反的洗脱顺序使 HILIC 成为更常用的 RPLC 的一个很好的补充技术。对于极性分析物和离子化分析物尤其如此，它们在 HILIC 模式下的保留时间更长。</li></ul><h1 id="参考"><a class="anchor" href="#参考">#</a> 参考</h1><ul><li><span class="exturl" data-url="aHR0cDovL3d3dy5iaW9lbmd4LmNvbS8lRTglQjQlQTglRTglQjAlQjElRTUlODglODYlRTYlOUUlOTAlRTYlOUMlQUYlRTglQUYlQUQlRTYlOUMlODAlRTUlODUlQTglRTglQTclQTMlRTglQUYlQkIv">质谱分析术语最全解读</span></li><li><span class="exturl" data-url="aHR0cHM6Ly93d3cudGlkeW1hc3Mub3JnL3N0YXJ0L3dob2xlX3dvcmtmbG93Lw==">Whole workflow using tidymass</span></li><li><span class="exturl" data-url="aHR0cHM6Ly93d3cuYWdpbGVudC5jb20vY3MvbGlicmFyeS9hcHBsaWNhdGlvbnMvYXBwbGljYXRpb24tbm90ZS1oaWxpYyUyMHZlcnN1cy1ycGxjLTU5OTQtMTEzN3poLWNuLWFnaWxlbnQucGRm">极性分子的保留和分离 ― 关于何时使用 HILIC 与反相液相色谱柱的详细研究</span></li></ul><h1 id="加关注"><a class="anchor" href="#加关注">#</a> 加关注</h1><p>关注公众号 “生信之巅”。</p><table align="center"><tr><td align="center"><img data-src="https://cdn.jsdelivr.net/gh/liaochenlanruo/cdn@master/img/social/生信之巅公众号.jpg" alt="生信之巅微信公众号" style="width:100px;height:100px;vertical-align:-20px;border-radius:0;margin-right:0;margin-bottom:5px;align:center"></td><td align="center"><img data-src="https://cdn.jsdelivr.net/gh/liaochenlanruo/cdn@master/img/social/小程序码.png" alt="生信之巅小程序码" style="width:100px;height:100px;vertical-align:-20px;border-radius:0;margin-left:0;margin-bottom:5px;align:center"></td></tr></table><p><font color="#FF0000"><ruby><b>敬告</b>：使用文中脚本请引用本文网址，请尊重本人的劳动成果，谢谢！<rt><b>Notice</b>: When you use the scripts in this article, please cite the link of this webpage. Thank you!</rt></ruby></font></p><div class="tags"><a href="/tags/%E7%94%9F%E4%BF%A1%E8%BD%AF%E4%BB%B6/" rel="tag"><i class="ic i-tag"></i> 生信软件</a> <a href="/tags/%E4%BB%A3%E8%B0%A2%E7%BB%84/" rel="tag"><i class="ic i-tag"></i> 代谢组</a></div></div><footer><div class="meta"><span class="item"><span class="icon"><i class="ic i-calendar-check"></i> </span><span class="text">Edited on</span> <time title="Modified: 2023-05-19 08:57:07" itemprop="dateModified" datetime="2023-05-19T08:57:07+08:00">2023-05-19</time> </span><span id="post/0.html" class="item leancloud_visitors" data-flag-title="基于TidyMass的非靶向代谢组学分析" title="Views"><span class="icon"><i class="ic i-eye"></i> </span><span class="text">Views</span> <span class="leancloud-visitors-count"></span> <span class="text">times</span></span></div><div class="reward"><button><i class="ic i-heartbeat"></i> Donate</button><p>Give me a cup of [coffee]~(￣▽￣)~*</p><div id="qr"><div><img data-src="/images/reward-wepays.jpg" alt="Hualin Liu WeChat Pay"><p>WeChat Pay</p></div><div><img data-src="/images/AliPays.jpg" alt="Hualin Liu Alipay"><p>Alipay</p></div></div></div><div id="copyright"><ul><li class="author"><strong>Post author: </strong>liaochenlanruo <i class="ic i-at"><em>@</em></i>了尘兰若的小坑</li><li class="link"><strong>Post link: </strong><a href="https://liaochenlanruo.gitee.io/post/0.html" title="基于TidyMass的非靶向代谢组学分析">https://liaochenlanruo.gitee.io/post/0.html</a></li><li class="license"><strong>Copyright Notice: </strong>All articles in this blog are licensed under <span class="exturl" data-url="aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzQuMC9kZWVkLnpo"><i class="ic i-creative-commons"><em>(CC)</em></i>BY-NC-SA</span> unless stating additionally.</li></ul></div></footer></article></div><div class="post-nav"><div class="item left"><a href="/post/df57.html" itemprop="url" rel="prev" data-background-image="https:&#x2F;&#x2F;cdn.jsdelivr.net&#x2F;gh&#x2F;liaochenlanruo&#x2F;cdn@master&#x2F;img&#x2F;custom&#x2F;bgs&#x2F;thumb_104.webp" title="用metid构建代谢组数据库"><span class="type">Previous Post</span> <span class="category"><i class="ic i-flag"></i> 生物信息</span><h3>用metid构建代谢组数据库</h3></a></div><div class="item right"><a href="/post/29bf.html" itemprop="url" rel="next" data-background-image="https:&#x2F;&#x2F;cdn.jsdelivr.net&#x2F;gh&#x2F;liaochenlanruo&#x2F;cdn@master&#x2F;img&#x2F;custom&#x2F;bgs&#x2F;thumb_106.webp" title="批量下载某研究方向重要文献"><span class="type">Next Post</span> <span class="category"><i class="ic i-flag"></i> 生物信息</span><h3>批量下载某研究方向重要文献</h3></a></div></div><div class="wrap" id="comments"></div></div><div id="sidebar"><div class="inner"><div class="panels"><div class="inner"><div class="contents panel pjax" data-title="Contents"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BB%A3%E8%B0%A2%E7%BB%84%E5%AD%A6%E5%B8%B8%E7%94%A8%E4%BB%AA%E5%99%A8%E7%89%B9%E7%82%B9"><span class="toc-number">1.</span> <span class="toc-text">代谢组学常用仪器特点</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#lc-qtof%E5%8E%9F%E7%90%86"><span class="toc-number">2.</span> <span class="toc-text">LC-QTOF 原理</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90"><span class="toc-number">3.</span> <span class="toc-text">数据分析</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%8B%E6%9C%BA%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F%E8%BD%AC%E6%8D%A2"><span class="toc-number">3.1.</span> <span class="toc-text">下机数据格式转换</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#proteowizard"><span class="toc-number">3.1.1.</span> <span class="toc-text">ProteoWizard</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#massconverter"><span class="toc-number">3.1.2.</span> <span class="toc-text">massconverter</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AE%89%E8%A3%85"><span class="toc-number">3.1.2.1.</span> <span class="toc-text">安装</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%AE%BE%E7%BD%AE%E8%BD%AC%E6%8D%A2%E5%8F%82%E6%95%B0"><span class="toc-number">3.1.2.2.</span> <span class="toc-text">设置转换参数</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%BC%80%E5%A7%8B%E8%BD%AC%E6%8D%A2"><span class="toc-number">3.1.2.3.</span> <span class="toc-text">开始转换</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85tidymass"><span class="toc-number">3.2.</span> <span class="toc-text">安装 tidyMass</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8E%9F%E5%A7%8B%E6%95%B0%E6%8D%AE%E5%A4%84%E7%90%86"><span class="toc-number">3.3.</span> <span class="toc-text">原始数据处理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%AD%A3%E7%A6%BB%E5%AD%90%E6%A8%A1%E5%BC%8F"><span class="toc-number">3.3.1.</span> <span class="toc-text">正离子模式</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%B4%9F%E7%A6%BB%E5%AD%90%E6%A8%A1%E5%BC%8F"><span class="toc-number">3.3.2.</span> <span class="toc-text">负离子模式</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#explore-data"><span class="toc-number">3.4.</span> <span class="toc-text">Explore data</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%AD%A3%E7%A6%BB%E5%AD%90%E6%A8%A1%E5%BC%8F-2"><span class="toc-number">3.4.1.</span> <span class="toc-text">正离子模式</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%B4%9F%E7%A6%BB%E5%AD%90%E6%A8%A1%E5%BC%8F-2"><span class="toc-number">3.4.2.</span> <span class="toc-text">负离子模式</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E6%B8%85%E6%B4%97data-cleaning"><span class="toc-number">3.5.</span> <span class="toc-text">数据清洗（Data cleaning）</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E8%B4%A8%E9%87%8F"><span class="toc-number">3.5.1.</span> <span class="toc-text">查看质量</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BC%80%E5%A7%8B%E6%B8%85%E6%B4%97"><span class="toc-number">3.5.2.</span> <span class="toc-text">开始清洗</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E7%A7%BB%E9%99%A4%E5%99%AA%E9%9F%B3%E4%BB%A3%E8%B0%A2features%E7%BC%BA%E5%A4%B1%E5%80%BC%E8%BF%87%E6%BB%A4"><span class="toc-number">3.5.2.1.</span> <span class="toc-text">移除噪音代谢 features—— 缺失值过滤。</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%BF%87%E6%BB%A4%E7%A6%BB%E7%BE%A4%E6%A0%B7%E6%9C%ACfilter-outlier-samples"><span class="toc-number">3.5.2.2.</span> <span class="toc-text">过滤离群样本（Filter outlier samples）</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BC%BA%E5%A4%B1%E5%80%BC%E5%A1%AB%E5%85%85missing-value-imputation"><span class="toc-number">3.6.</span> <span class="toc-text">缺失值填充（Missing value imputation）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E6%A0%87%E5%87%86%E5%8C%96%E4%B8%8E%E6%95%B4%E5%90%88data-normalization-and-integration"><span class="toc-number">3.7.</span> <span class="toc-text">数据标准化与整合（Data normalization and integration）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%A3%E8%B0%A2%E7%89%A9%E6%B3%A8%E9%87%8A"><span class="toc-number">3.8.</span> <span class="toc-text">代谢物注释</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8A%A0%E8%BD%BD%E6%95%B0%E6%8D%AE"><span class="toc-number">3.8.1.</span> <span class="toc-text">加载数据</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%86ms2%E6%95%B0%E6%8D%AE%E6%B7%BB%E5%8A%A0%E5%88%B0mass_dataset"><span class="toc-number">3.8.2.</span> <span class="toc-text">将 MS2 数据添加到 mass_dataset</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BB%A3%E8%B0%A2%E7%89%A9%E6%B3%A8%E9%87%8A-2"><span class="toc-number">3.8.3.</span> <span class="toc-text">代谢物注释</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E6%B3%A8%E9%87%8A%E7%BB%93%E6%9E%9C"><span class="toc-number">3.8.4.</span> <span class="toc-text">查看注释结果</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BF%9D%E5%AD%98%E6%95%B0%E6%8D%AE"><span class="toc-number">3.8.5.</span> <span class="toc-text">保存数据</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BB%9F%E8%AE%A1%E5%88%86%E6%9E%90"><span class="toc-number">3.9.</span> <span class="toc-text">统计分析</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8A%A0%E8%BD%BD%E6%95%B0%E6%8D%AE-2"><span class="toc-number">3.9.1.</span> <span class="toc-text">加载数据</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%A7%BB%E9%99%A4%E6%9C%AA%E8%A2%AB%E6%B3%A8%E9%87%8A%E7%9A%84features"><span class="toc-number">3.9.2.</span> <span class="toc-text">移除未被注释的 features</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%90%88%E5%B9%B6pos%E5%92%8Cneg%E6%95%B0%E6%8D%AE"><span class="toc-number">3.9.3.</span> <span class="toc-text">合并 POS 和 NEG 数据</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#trace-processing-information-of-object"><span class="toc-number">3.9.4.</span> <span class="toc-text">Trace processing information of object</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9F%BA%E4%BA%8Elevel%E5%92%8Cscore%E7%A7%BB%E9%99%A4%E5%86%97%E4%BD%99%E6%B3%A8%E9%87%8A%E4%BB%A3%E8%B0%A2%E7%89%A9"><span class="toc-number">3.9.5.</span> <span class="toc-text">基于 level 和 score 移除冗余注释代谢物</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%A0%B7%E6%9C%AC%E8%81%9A%E7%B1%BB"><span class="toc-number">3.9.6.</span> <span class="toc-text">样本聚类</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B7%AE%E5%BC%82%E8%A1%A8%E8%BE%BE%E4%BB%A3%E8%B0%A2%E7%89%A9"><span class="toc-number">3.9.7.</span> <span class="toc-text">差异表达代谢物</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BF%9D%E5%AD%98%E7%BB%93%E6%9E%9C"><span class="toc-number">3.9.8.</span> <span class="toc-text">保存结果</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BB%98%E5%88%B6%E7%83%AD%E5%9B%BE"><span class="toc-number">3.9.9.</span> <span class="toc-text">绘制热图</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%A3%E8%B0%A2%E9%80%9A%E8%B7%AF%E5%AF%8C%E9%9B%86"><span class="toc-number">3.10.</span> <span class="toc-text">代谢通路富集</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AF%BC%E5%85%A5%E6%95%B0%E6%8D%AE"><span class="toc-number">3.10.1.</span> <span class="toc-text">导入数据</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AF%8C%E9%9B%86"><span class="toc-number">3.10.1.1.</span> <span class="toc-text">富集</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8A%A0%E8%BD%BDkegg-human-pathway%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-number">3.10.2.</span> <span class="toc-text">加载 KEGG human pathway 数据库</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BB%98%E5%88%B6%E7%BB%93%E6%9E%9C"><span class="toc-number">3.10.3.</span> <span class="toc-text">绘制结果</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#correlation-network-analysis"><span class="toc-number">3.11.</span> <span class="toc-text">Correlation network analysis</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%9C%AF%E8%AF%AD"><span class="toc-number">4.</span> <span class="toc-text">术语</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8F%82%E8%80%83"><span class="toc-number">5.</span> <span class="toc-text">参考</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8A%A0%E5%85%B3%E6%B3%A8"><span class="toc-number">6.</span> <span class="toc-text">加关注</span></a></li></ol></div><div class="related panel pjax" data-title="Related"><ul><li><a href="/post/19824.html" rel="bookmark" title="生物信息学1：VMware虚拟机及Bio-linux安装与配置">生物信息学1：VMware虚拟机及Bio-linux安装与配置</a></li><li><a href="/post/9.html" rel="bookmark" title="生物信息学2：VirtualBox虚拟机及Bio-Linux安装">生物信息学2：VirtualBox虚拟机及Bio-Linux安装</a></li><li><a href="/post/10877.html" rel="bookmark" title="生物信息学3：微生物基因组学常用软件安装">生物信息学3：微生物基因组学常用软件安装</a></li><li><a href="/post/30650.html" rel="bookmark" title="根据基因组预测表型 —— traitar的安装与使用">根据基因组预测表型 —— traitar的安装与使用</a></li><li><a href="/post/44606.html" rel="bookmark" title="kSNP3寻找SNPs并构建进化树">kSNP3寻找SNPs并构建进化树</a></li><li><a href="/post/43504.html" rel="bookmark" title="用wget批量下载含有链接的文件/目录">用wget批量下载含有链接的文件/目录</a></li><li><a href="/post/94f2.html" rel="bookmark" title="为PubMed添加功能">为PubMed添加功能</a></li><li><a href="/post/4e1.html" rel="bookmark" title="OrthoFinder2—同源蛋白家族聚类">OrthoFinder2—同源蛋白家族聚类</a></li><li><a href="/post/848f.html" rel="bookmark" title="PGCGAP中文说明">PGCGAP中文说明</a></li><li><a href="/post/d163.html" rel="bookmark" title="Bioconda贡献指南">Bioconda贡献指南</a></li><li><a href="/post/f6c9.html" rel="bookmark" title="Linux和基因组测序技术初识">Linux和基因组测序技术初识</a></li><li><a href="/post/5908.html" rel="bookmark" title="BtToxin_Digger--A high-throughput Bacillus thuringiensis toxin mining pipeline">BtToxin_Digger--A high-throughput Bacillus thuringiensis toxin mining pipeline</a></li><li><a href="/post/ab1b.html" rel="bookmark" title="宏基因组分析流程及代码">宏基因组分析流程及代码</a></li><li><a href="/post/4cf4.html" rel="bookmark" title="Use microeco分析扩增子数据">Use microeco分析扩增子数据</a></li><li><a href="/post/1755.html" rel="bookmark" title="扩增子分析--计算随机过程和决定性过程比例">扩增子分析--计算随机过程和决定性过程比例</a></li><li><a href="/post/e7e9.html" rel="bookmark" title="根据assession number批量从NCB下载数据">根据assession number批量从NCB下载数据</a></li><li><a href="/post/e922.html" rel="bookmark" title="Swissprot数据库的本地化与序列比对并与其他数据库快速mapping">Swissprot数据库的本地化与序列比对并与其他数据库快速mapping</a></li><li><a href="/post/412a.html" rel="bookmark" title="构建样本vs基因矩阵">构建样本vs基因矩阵</a></li><li><a href="/post/9052.html" rel="bookmark" title="CAZy碳水化合物活性酶预测">CAZy碳水化合物活性酶预测</a></li><li><a href="/post/5324.html" rel="bookmark" title="原核生物基因岛预测">原核生物基因岛预测</a></li><li><a href="/post/d9f9.html" rel="bookmark" title="按照Contig切割GenBank文件">按照Contig切割GenBank文件</a></li><li><a href="/post/3a23.html" rel="bookmark" title="从GenBank文件中提取Features">从GenBank文件中提取Features</a></li><li><a href="/post/fb68.html" rel="bookmark" title="使用EffectiveT3预测微生物中的III型分泌系统效应蛋白">使用EffectiveT3预测微生物中的III型分泌系统效应蛋白</a></li><li><a href="/post/c886.html" rel="bookmark" title="SignalP+TMHMM预测微生物分泌蛋白">SignalP+TMHMM预测微生物分泌蛋白</a></li><li><a href="/post/6a93.html" rel="bookmark" title="在FASTA文件中搜索完全匹配的短序列">在FASTA文件中搜索完全匹配的短序列</a></li><li><a href="/post/ea71.html" rel="bookmark" title="在Linux服务器中安装网页版Rstudio">在Linux服务器中安装网页版Rstudio</a></li><li><a href="/post/a713.html" rel="bookmark" title="R语言安装依赖包错误集锦">R语言安装依赖包错误集锦</a></li><li><a href="/post/d444.html" rel="bookmark" title="NCBI上传基因簇之tbl2asn的使用">NCBI上传基因簇之tbl2asn的使用</a></li><li><a href="/post/18ea.html" rel="bookmark" title="利用NCycDB数据库从宏基因组中预测氮循环基因">利用NCycDB数据库从宏基因组中预测氮循环基因</a></li><li><a href="/post/36cc.html" rel="bookmark" title="R语言绘制分组条形图">R语言绘制分组条形图</a></li><li><a href="/post/1551.html" rel="bookmark" title="宏病毒组分析流程1-VirSorter2">宏病毒组分析流程1-VirSorter2</a></li><li><a href="/post/8fb3.html" rel="bookmark" title="利用GTDB-TK对细菌和古菌基因组进行物种分类">利用GTDB-TK对细菌和古菌基因组进行物种分类</a></li><li><a href="/post/85d7.html" rel="bookmark" title="计算蛋白质等电点并绘制全局pI图">计算蛋白质等电点并绘制全局pI图</a></li><li><a href="/post/92eb.html" rel="bookmark" title="使用DeepARG预测抗生素抗性基因ARGs">使用DeepARG预测抗生素抗性基因ARGs</a></li><li><a href="/post/74ad.html" rel="bookmark" title="Nanopore基因组组装">Nanopore基因组组装</a></li><li><a href="/post/2581.html" rel="bookmark" title="使用eggNOG-mapper注释基因组">使用eggNOG-mapper注释基因组</a></li><li><a href="/post/d862.html" rel="bookmark" title="PGCGAP - the Prokaryotic Genomics and Comparative Genomics Analysis Pipeline v1.0.33">PGCGAP - the Prokaryotic Genomics and Comparative Genomics Analysis Pipeline v1.0.33</a></li><li><a href="/post/e6ae.html" rel="bookmark" title="利用PGCGAP根据ids提取序列信息">利用PGCGAP根据ids提取序列信息</a></li><li><a href="/post/213.html" rel="bookmark" title="多种方法批量下载NCBI基因组">多种方法批量下载NCBI基因组</a></li><li><a href="/post/33b.html" rel="bookmark" title="代谢组相关软件的安装及使用">代谢组相关软件的安装及使用</a></li><li><a href="/post/377e.html" rel="bookmark" title="使用xcms3处理和分析LC-MS数据">使用xcms3处理和分析LC-MS数据</a></li><li><a href="/post/df57.html" rel="bookmark" title="用metid构建代谢组数据库">用metid构建代谢组数据库</a></li><li class="active"><a href="/post/0.html" rel="bookmark" title="基于TidyMass的非靶向代谢组学分析">基于TidyMass的非靶向代谢组学分析</a></li><li><a href="/post/29bf.html" rel="bookmark" title="批量下载某研究方向重要文献">批量下载某研究方向重要文献</a></li><li><a href="/post/c617.html" rel="bookmark" title="16S扩增子测序及宏基因组测序">16S扩增子测序及宏基因组测序</a></li><li><a href="/post/1177.html" rel="bookmark" title="用MaAsLin2包做微生物组多变量线性模型关联分析">用MaAsLin2包做微生物组多变量线性模型关联分析</a></li><li><a href="/post/7449.html" rel="bookmark" title="NCBI上传基因簇之table2asn的使用">NCBI上传基因簇之table2asn的使用</a></li></ul></div><div class="overview panel" data-title="Overview"><div class="author" itemprop="author" itemscope itemtype="http://schema.org/Person"><img class="image" itemprop="image" alt="Hualin Liu" data-src="/images/head.jpg"><p class="name" itemprop="name">Hualin Liu</p><div class="description" itemprop="description">分享微生物生物信息学分析方法，欢迎加入QQ群交流945751012，不接受群内广告！</div></div><nav class="state"><div class="item posts"><a href="/archives/"><span class="count">130</span> <span class="name">posts</span></a></div><div class="item categories"><a href="/categories/"><span class="count">12</span> <span class="name">categories</span></a></div><div class="item tags"><a href="/tags/"><span class="count">54</span> <span class="name">tags</span></a></div></nav><div class="social"><span class="exturl item github" data-url="aHR0cDovL2dpdGh1Yi5jb20vbGlhb2NoZW5sYW5ydW8=" title="http:&#x2F;&#x2F;github.com&#x2F;liaochenlanruo"><i class="ic i-github"></i></span> <span class="exturl item zhihu" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9zdWFuLWxhLW1pYW4tcGlhbi10YW5nLWNpdW0=" title="https:&#x2F;&#x2F;www.zhihu.com&#x2F;people&#x2F;suan-la-mian-pian-tang-cium"><i class="ic i-zhihu"></i></span> <span class="exturl item weibo" data-url="aHR0cHM6Ly93ZWliby5jb20vdS8yNzE1MjEwOTIz" title="https:&#x2F;&#x2F;weibo.com&#x2F;u&#x2F;2715210923"><i class="ic i-weibo"></i></span> <span class="exturl item about" data-url="aHR0cHM6Ly93d3cubGlhb2NoZW5sYW5ydW8uZnVuL2Fib3V0" title="https:&#x2F;&#x2F;www.liaochenlanruo.fun&#x2F;about"><i class="ic i-address-card"></i></span> <span class="exturl item email" data-url="bWFpbHRvOmxpYW9jaGVubGFucnVvQHdlYm1haWwuaHphdS5lZHUuY24=" title="mailto:liaochenlanruo@webmail.hzau.edu.cn"><i class="ic i-envelope"></i></span> <span class="exturl item douban" data-url="aHR0cHM6Ly93d3cuZG91YmFuLmNvbS9wZW9wbGUvbGlhb2NoZW5sYW5ydW8vP19pPTczNDYxMjVRalo1QjZWLw==" title="https:&#x2F;&#x2F;www.douban.com&#x2F;people&#x2F;liaochenlanruo&#x2F;?_i&#x3D;7346125QjZ5B6V&#x2F;"><i class="ic i-douban"></i></span> <span class="exturl item google" data-url="aHR0cHM6Ly9zY2hvbGFyLmdvb2dsZS5jby5qcC9jaXRhdGlvbnM/dXNlcj1YYW9STk1RQUFBQUomaGw9amE=" title="https:&#x2F;&#x2F;scholar.google.co.jp&#x2F;citations?user&#x3D;XaoRNMQAAAAJ&amp;hl&#x3D;ja"><i class="ic i-google"></i></span></div><ul class="menu"><li class="item"><a href="/" rel="section"><i class="ic i-home"></i>Home</a></li><li class="item dropdown"><a href="javascript:void(0);"><i class="ic i-user"></i>About</a><ul class="submenu"><li class="item"><a href="/about/" rel="section"><i class="ic i-user"></i>About me</a></li><li class="item"><a href="/comment/" rel="section"><i class="ic i-envelope"></i>Comment</a></li></ul></li><li class="item dropdown"><a href="javascript:void(0);"><i class="ic i-feather"></i>Posts</a><ul class="submenu"><li class="item"><a href="/archives/" rel="section"><i class="ic i-list-alt"></i>Archives</a></li><li class="item"><a href="/categories/" rel="section"><i class="ic i-th"></i>Categories</a></li><li class="item"><a href="/tags/" rel="section"><i class="ic i-tags"></i>Tags</a></li></ul></li><li class="item dropdown"><a href="javascript:void(0);"><i class="ic i-list-ol"></i>List</a><ul class="submenu"><li class="item"><a href="/photos/" rel="section"><i class="ic i-person"></i>Photos</a></li><li class="item"><a href="/skip/gallery/" rel="section"><i class="ic i-cloud"></i>Gallery</a></li><li class="item"><a href="/skip/box/" rel="section"><i class="ic i-magic"></i>Box</a></li><li class="item"><span class="exturl" data-url="aHR0cHM6Ly9saWFvY2hlbmxhbnJ1by5mdW4vcmVmZXJlbmNlLw=="><i class="ic i-th"></i>cheatsheets</span></li></ul></li><li class="item"><a href="/donate/" rel="section"><i class="ic i-coffee"></i>Donate</a></li><li class="item"><a href="/friends/" rel="section"><i class="ic i-heart"></i>Friends</a></li><li class="item"><span class="exturl" data-url="aHR0cHM6Ly9saWFvY2hlbmxhbnJ1by5naXRodWIuaW8="><i class="ic i-external-link-alt"></i>中文版</span></li><li class="item"><span class="exturl" data-url="aHR0cHM6Ly90cmF2ZWxsaW5ncy5saW5r"><i class="ic i-forward"></i>Travelling</span></li></ul></div></div></div><ul id="quick"><li class="prev pjax"><a href="/post/df57.html" rel="prev" title="Previous Post"><i class="ic i-chevron-left"></i></a></li><li class="up"><i class="ic i-arrow-up"></i></li><li class="down"><i class="ic i-arrow-down"></i></li><li class="next pjax"><a href="/post/29bf.html" rel="next" title="Next Post"><i class="ic i-chevron-right"></i></a></li><li class="percent"></li></ul></div></div><div class="dimmer"></div></div></main><footer id="footer"><div class="inner"><div class="widgets"></div><div class="status"><div class="copyright">&copy; 2018 – <span itemprop="copyrightYear">2024</span> <span class="with-love"><i class="ic i-sakura rotate"></i> </span><span class="author" itemprop="copyrightHolder">Hualin Liu @ ResearchGo</span></div><div class="count"><span class="post-meta-item-icon"><i class="ic i-chart-area"></i> </span><span title="Symbols count total">788k words</span> <span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="ic i-coffee"></i> </span><span title="Reading time total">11:57</span><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="ic i-info-circle"></i> </span><span style="padding-left:1px"><span id="busuanzi_container_site_pv">Total visits: <span id="busuanzi_value_site_pv" style="color:#f99"></span> times</span> <span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="ic i-user"></i> </span><span style="padding-left:1px"><span id="busuanzi_container_site_uv">Total visitors: <span id="busuanzi_value_site_uv" style="color:#f99"></span> people</span></span></span></div><div class="powered-by">Powered by <span class="exturl" data-url="aHR0cHM6Ly9oZXhvLmlv">Hexo</span> & Theme.<span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2FtZWhpbWUvaGV4by10aGVtZS1zaG9rYQ==">Shoka</span></div></div></div></footer></div><script data-config type="text/javascript">var LOCAL={path:"post/0.html",favicon:{show:"（●´3｀●）Goooood",hide:"(´Д｀)Booooom"},search:{placeholder:"Search for Posts",empty:"We didn't find any results for the search: ${query}",stats:"${hits} results found in ${time} ms"},valine:!0,fancybox:!0,copyright:'Copied to clipboard successfully! <br> All articles in this blog are licensed under <i class="ic i-creative-commons"></i>BY-NC-SA.',ignores:[function(e){return e.includes("#")},function(e){return new RegExp(LOCAL.path+"$").test(e)}]}</script><script src="https://cdn.polyfill.io/v2/polyfill.js"></script><script src="//cdn.jsdelivr.net/combine/npm/pace-js@1.0.2/pace.min.js,npm/pjax@0.2.8/pjax.min.js,npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js,npm/animejs@3.2.0/lib/anime.min.js,npm/algoliasearch@4/dist/algoliasearch-lite.umd.js,npm/instantsearch.js@4/dist/instantsearch.production.min.js,npm/lozad@1/dist/lozad.min.js,npm/quicklink@2/dist/quicklink.umd.js"></script><script src="/js/app.js?v=0.2.5"></script><script data-pjax>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?d211830a796ceefb38a141fde14e4d5a";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script></body></html>